| Krue (2) | |
|
the code is strcpy(p->data, text); text is a const char* and p->data is a UDPpacket* from SDL_net. it works perfectly in C but when the exact same command is called in c++ it gives me this error: error: invalid conversion from ‘Uint8* {aka unsigned char*}’ to ‘char*’ [-fpermissive]| /usr/include/string.h|128|error: initializing argument 1 of ‘char* strcpy(char*, const char*)’ | |
|
|
|
| Moschops (5956) | |
| Cast p->data as a char pointer. | |
|
|
|
| Disch (8337) | |||
|
C++ is more type-strict than C. C is allowing the pointer to be implicitly cast, whereas C++ sees that the types are not similar and gives you an error. You can explicitly cast to get around the error:
| |||
|
|
|||
| Krue (2) | |
| thanks, i cannot beleive i didn't solve this myself it is so simple and obvious now. btw, this is for a functioning 3d game i'm writing :) | |
|
|
|