|
| |||||||||||||||||||||||||||||||||||||||||||||||||
| tqa (10) | |||||
|
I am doing a network relay program using socket programming to connect all the nodes. Basically, the server will connect to one client and will pass an information to it. The information that i want to send is a .txt format (text file).As far as I know, it is very difficult to send text file over socket. So, I think it will be better for me to send the data as a string. This is my partial code to send the array of string.
in sckt.h, byte define as follows
and it gives this error: error:invalid conversion form 'sckt::byte*' to 'char*' error:initializing argument 1 of 'char* strcpy(char* , const char*)' can anyone help me please.. and I hope that my question is clear =) Thanks in advance | |||||
|
Last edited on
|
|||||
| jsmith (5804) | |
|
char* (what strcpy expects) is not the same as unsigned char* (the type of sckt::byte). You have to cast. strcpy( static_cast<char*>( data ), list[n].c_str() ); Or just make data a char array to begin with. Some other things to note: 1) Using a variable named list can be dangerous in light of the STL list container. 2) Line 8 is a buffer overflow waiting to happen. | |
|
|
|
| tqa (10) | |
|
Thanks for the suggestion! But when I run and compile the code. This error occur, error: invalid static_cast from type ‘sckt::byte [256]’ to type ‘char*’ | |
|
|
|
| jsmith (5804) | |||
Sorry, try
| |||
|
|
|||
| tqa (10) | |
thanks for the idea..my code run as im using this strcpy( reinterpret_cast <char*> (data), arraylist2[g].c_str()); =)) | |
|
|
|