how to print a char from struct
Posted
by make
on Stack Overflow
See other posts from Stack Overflow
or by make
Published on 2010-03-12T00:49:39Z
Indexed on
2010/03/12
1:07 UTC
Read the original article
Hit count: 210
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?
...
Thanks for your replies-
© Stack Overflow or respective owner