I am trying to strip off the trailing \n char that fgets() appends. I am replacing this character with a string terminating char, \0.
Why is the compiler giving the error: "Assignment makes integer from pointer without cast".
word[strlen(word) - 1] = "\0";
Here's a more complete sample of the code is question in case some context is needed.
FILE *wordFile = fopen("/temp/words.txt", "r");
char word[100];
while (fgets(word, 100, wordFile)) {
// Strip off the trailing the \n so it is not counted
// as part of the string length
word[strlen(word) - 1] = "\0";
:
}
"\0"instead of'\0'...'\n'in your word (say, the input ended with an EOF or reached your buffer size without the'\n'), it'll happily chop off the last character in your word.