On , Mark Trickett (3:633/371@fidonet) wrote:
RS> main()
> Ouch.... what about int main()? You must be tired and / or busy to do that
> even in such code as this!
Mark...
Just lazy, actually. Besides, according to ANSI/ISO, what I used is
equivalent to...
int main(void)
...(assuming I didn't include operand definitions between the function
definition and the following body, e.g...
main()
int argc;
char *argv[];
{
...
}
...which is the same as...
int main(int argc, char *argv[])
RS> {
RS> char buf[80]; /* Nice & roomy */
RS> struct TAG {
RS> char *name;
RS> char *address1;
RS> char *address2;
RS> char *address3;
RS> } my_data[3];
> Yes, but if I do not know in advance how many elements in the array?
In the example, there is room for only 3 elements in the my_data array. To
make it larger, declare my_data as a pointer, then allocate each element
using realloc(). Alternatively, you could make it a linked list instead of an
array.
I'll provide code examples and answer the rest of your questions in a day
or so - right now I'm tired from a crash week.
--- QM v1.00
---------------
* Origin: MicroFirm : Down to the C in chips (1:106/2000.6)
|