
please help with this program
Quote:
(Lasse V?gs?ther Karlsen) writes:
>> The error says:
>> Error: parts_db.cpp(67,12):Cannot convert 'void *' to Appt *'
>> struct Appt *cur, *prev, *new_node;
>> new_node = malloc (sizeof(struct Appt));
> If this is the line in question, modify it to read
> new_node = (Appt *)malloc (sizeof(struct Appt));
If the code and error message were really as stated, a better
solution would be to get a C compiler. (It sounds as if Ryan may
be using a C++ compiler.) If malloc() is correctly declared as
returning void * (as the error message strongly implies that it
is), then the lines
struct Appt *new_node;
new_node = malloc (sizeof(struct Appt));
are 100% correct, and a C compiler has no reason to complain.
(In particular, the whole point of the void * type is that it
*is* possible to (implicitly) convert a void * value into any
other type of object pointer, including struct Appt *.
I hear, though, that the situation is different in C++.)
[Oh. Duh. "parts_db.cpp". I guess another better solution
would be to post the question to comp.lang.c++, then. I guess
I don't even need to post this followup, since my clue about
parts_db.cpp came from the followup I just noticed that Lawrence
Kirby posted already.]
Steve Summit