I have a simple TCP connection with a server and a client program. I made a simple struct in both the server and the client to pass as the message:
struct {int c; char** v;} msg;
I am just trying to send the argc and argv (input from terminal) from the client:
int main(int argc, char **argv){
...
msg.c = argc;
msg.v = argv;
sendto(Socket, &msg, sizeof(msg), 0, (struct sockaddr *)&input, sizeof(input));
but when sent to the server I can call msg.c to get the number and I can use that but if I try to use the array of strings I get a seg fault:
recvfrom(Socket, &msg, sizeof(msg), 0, (struct sockaddr *)&input, &sizep);
printf("%d\n", msg.c);
printf("%s\n", msg.v[2]);
I have tried this with just one char * and I wasn't able to send the string across either.
What am I doing wrong?