I'm really raw with C, and am having trouble with a cast. Here are the lines of my code that I think are relevant:
#define BUF 1025
char hostname[BUF];
hostname = *(char *) qpop(&queue);
And this is the error that I am getting from the compiler:
error: incompatible types when assigning to type 'char[1025]' from type char
Note that the function qpop returns a void*. I think that my issue is how to cast from a void* into char[1025]. From the error message, I seem to be casting to type char, but not to type char[1025]. I tried this:
hostname = *(char[1025] *) qpop(&queue)
but that didn't work either.
Can somebody help me understand how to do this? Thank you!
void*needs no casting to assign it to another pointer type. Additionally, the extra*isn't doing any casting at all, it's doing a dereference. - Cornstalks