Why does comparing the result of scanf() with NULL generate a compiler warning?
问题 I'm writing in C and I need to read everything that arrives in input but I don't know how many characters I will receive. I wrote while (scanf("%c", &read) != NULL) but the compiler tells me: [Warning] comparison between pointer and integer , so what should I write instead? 回答1: Instead, of scanf("%c", &read) you may consider read = getc(stdin). Please, be aware that getc() / fgetc() return int . This allows to store any character as number in range [0, 255] as well as to return EOF (usually