I'm trying to send two strings from client to server but only the first string is successfully passed, the second one doesn't seem to work.
client code
char *a[2];
char temp[100];
printf("Enter name of file : ");
scanf("%s", temp);
a[0] = malloc(strlen(temp) + 1);
strcpy(a[0],temp);
printf("Enter name of operation : ");
scanf("%s", temp);
a[1] = malloc(strlen(temp) + 1);
strcpy(a[1],temp);
int i = 0;
while(i<2)
{
send(sock , a[i], sizeof(a[i]), 0 );
i++;
}
Server code:
int i = 0;
char *buffer[2];
while (i < 2)
{
buffer[i] = malloc(1000);
int size = read(new_socket, buffer[i], 1000);
buffer[i][size] = '\0';
printf("BUFF : %s\n", buffer[i]);
printf("Size : %d\n", size);
i++;
}
printf("%s\n", buffer[0]);
printf("%s\n", buffer[1]);
Input:
Enter file name : w
Enter operation code : 1f
output: