Code:
/* Demonstrates using the gets() return value. */
#include <stdio.h>
/* Declare a character array to hold input, and a pointer. */
char input[257], *ptr;
int main( void )
{
/* Display instructions. */
puts("Enter text a line at a time, then press Enter.");
puts("Enter a blank line when done.");
/* Loop as long as input is not a blank line. */
while ( (*ptr = gets(input)) != NULL)
printf("You entered %s\n", input);
puts("Thank you and good-bye\n");
return 0;
}
Whenever I try to compile the code above I get the error:
getback.c: In function ‘main’:
getback.c:18:34: warning: comparison between pointer and integer [enabled by default]
I just got this from the book that I am using and it is for testing for input of a blank line and readers are being warned in using this format (line 18):
Code:
while ( (*ptr = gets(input)) != NULL)
What is the correct syntax if a gcc compiler is to be used? Thanks.