[edit]
Its not wrong. (I will begin eating crow very soon...)Originally Posted by dwks
[/edit]
Well strchr returns NULL if it does not find the character you specified. So then, knowing that fgets will read in one less than size, it is quite possible that there will be no newline in the array. In that case you will get a NULL return from strchr, and in that case you will be dereferencing a NULL pointer, which is generally a Bad Thing.
edit::
You need the extra brackets with the != operator, otherwise you would have something like this:
thereby assigning either zero or non-zero to p.Code:if(p = (strchr(string_data, '\n') != NULL)) {