Parsing and data types problem...
Posted on 2003-10-21
...won't this hell ever end?
Is there any to "build" a UDP packet that can contain ints and chars? recvfrom() won't mind what kind of data it receives, that's up to the parsing, so can I create an array that will contain both these types? And this brings me another question; I'm parsing the received packets in the server side like this:
strncpy(oneInt,buffer,4); /*i copied a (char)int */
strncpy(string,&buffer,64); /*copied a 64B string*/
But how can I know if a char casted int will really take up 4B? Nevertheless, I need to send the array containing that int, so how can I retrieve it from the array later? I know I have to get 4B but how do I specify that in terms of positioning? Like this: myvar=buffer; ??? I don't think this is right! :((