How do I or is it possible to compare a structure member to a string?
Hi - with a specific question, I'd like to know if it is possible (I assume it is) to copy out a structures member to a variable and compare it to something else.
For example I have the following structure:
Code:
struct cmd_s {
char cmd[5];
char filename[256];
}
Once it is filled in I can see that the values are getting sent over my socket correctly, however I want to use an if statement to control my program flow.
Code:
struct cmd_s *cmdrecieved;
char bufferd[BUFFER_SIZE];
recvfrom(fd, bufferd, BUFFER_SIZE, 0, (struct sockaddr *)&srcaddr, (socklen_t*)&srcaddrSize );
cmdrecieved = (struct cmd_s *)bufferd;
printf( " before cmd = %s \n", cmdrecieved->cmd); // This works
//This is what I would like it to do
if (strcmp(cmdrecieved->cmd,"send")) {
printf( " awesome = %s \n", cmdrecieved->cmd);
} else
{
printf("she broken");
}
You can see the above code is wrong, but it should illustrate what I was trying to do.
Any suggestions?