does anyone know of common reasons to get seg faults with strcmp
I am reading a string of characters into a buffer, When I try to compare that buffer with the string "BYE" I get a seg. fault.
I know that "BYE" is in the buffer because I print it right before hand and that works fine. I was thinking that I can't just pass "BYE" straight into strcmp, but first setting a variable to old BYE and then passing that in didn't seem to work either. I have used strcmp and strncmp.
I am running FBSD Unix and using gcc to compile
Code:
fprintf(stderr,"recieved from socket: %s\n",buf);
if(strncmp(buf,"BYE",3) == 0){
fprintf(stderr,"exiting the program\n");
break;
}