THis isn't working! Help! =P
all = (words *) malloc(sizeof(words));
I get an error about the )!
and it looks just fine to me :(
Printable View
THis isn't working! Help! =P
all = (words *) malloc(sizeof(words));
I get an error about the )!
and it looks just fine to me :(
Looks ok, but let's see what you have 'all' declared as. Also, you don't have to cast malloc, or any other void* in C.
stuct words *ALL[50];
Is how words got defined! :)
Right. Casting the pointer returned from malloc will suppress warning messages that could help to reveal subtle coding errors.Quote:
Originally posted by Sebastiani
Looks ok, but let's see what you have 'all' declared as. Also, you don't have to cast malloc, or any other void* in C.
I am always amazed at how many "experienced" programmers don't know this, and I'm always pleased when I find one who does. :)
>stuct words *ALL[50];
>all = (words *) malloc(sizeof(words));
In C, the keyword struct would need to precede words. C is case sensitive, so ALL and all are different things.
Casting malloc
It might be beneficial to use the last form.