Hi
Could someone please tell us to print a char when receiving data as a struct? Here is an example:
...
struct rcv{
int x1;
float x2;
char *x3;
};
rcv data_rcv;
...
if (recv(socket, &data_rcv, sizeof(data_rcv), 0) < 0)
printf("recv() failed");
...
printf("x1 = %d\n", data_rcv.x1);
printf("x2 = %f\n", data_rcv.x2);
printf("x3 = %s\n", data_rcv.x3); // it doesn't print anything, why?
...
Let's suppose that x3 is string transfered through a socket, as such:
...
char *str1="data-of-app.1"
struct snd{
int x1;
float x2;
char *x3;
};
snd data_snd;
...
data_snd.snd = str1;
...
if (send(socket, &data_snd, sizeof(data_snd), 0) < 0)
printf("send() failed");
...
Thanks for your replies-