validate the input
Part of the code is as follows but not work
  printf("Ente开发者_如何学Pythonr a line of text (Enter to stop): ");
  fflush(stdin);
  fgets(input, 256, stdin);
  if (input == '\0') {
    exit(0);
  }
  .....
  .....
i want if the user only press enter, the program will be terminated. how to do it? thanks
Use if(*input == '\n') - if fgets reads a newline, it's stored in the buffer.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论