i've declared a structure as
typedef struct elem { int a; void *b[20]; }e;
how can i access the array of (void) pointer inside a structure???
e.b ???
- is this correct manner of accessing???
You seem to be confused about very basic things in C programming. Read a book on C. K&R is a good one.
The big issue is what you intend to do with your void pointers? Just store generic addresses or abuse them by typecast them to a lot of different types depending on time of day or your mood?
Most probably, you are running headlong into a very bad design.
"e.b ???
- is this correct manner of accessing???"
No, 'e' is a type, not an object that can be accessed.
"No, 'e' is a type, not an object that can be accessed."
The use of typedef together with structures almost always results in confusion for beginners. How it can be possible to give a name both before and after the struct, and still not end up with a variable of that type.
"The use of typedef together with structures almost always results in confusion for beginners."
My observation has been that beginners tend to overuse typedef without questioning the merits of using typedefs versus explicit structs. This is only my opinion; in instances where the user doesn't really care about or access a structure's members (e.g. FILE in stdio.h) typedef'ing a struct has merit, but if a user's code accesses members using "." or "->" operators, I don't see the value in hiding an object's "structness" behind a typedef name. Again, that's just my opinion, but I might remember it also being the opinion of pundits on comp.lang.c.
I believe the reason most people prefer to typedef every struct, union and enum is the same that drives a good part of C's syntax: brevity. People want to be able to just write "foo" instead of "struct foo" every time they use one.