Skip to main content
Spelling and grammar
Source Link
Toby Speight
  • 88.7k
  • 14
  • 104
  • 327

The main program can be simplified by using a function you probably haven't read about yet callcalled fgetsfgets. This function reads a line of text at a time. The variable lineline will contain the new line after the function has been called,called; you would need to remove the new linenewline before you reverse the input.

int main() { char line[BUFSIZ]; while (fgets(line, BUFSIZ, stdin) != NULL) { if (line[0]) { reverseLine(line); printf("%s\n", line); } } } 

The main program can be simplified by using a function you probably haven't read about yet call fgets. This function reads a line of text at a time. The variable line will contain the new line after the function has been called, you would need to remove the new line before you reverse the input.

int main() { char line[BUFSIZ]; while (fgets(line, BUFSIZ, stdin) != NULL) { if (line[0]) { reverseLine(line); printf("%s\n", line); } } } 

The main program can be simplified by using a function you probably haven't read about yet called fgets. This function reads a line of text at a time. The variable line will contain the new line after the function has been called; you would need to remove the newline before you reverse the input.

int main() { char line[BUFSIZ]; while (fgets(line, BUFSIZ, stdin) != NULL) { if (line[0]) { reverseLine(line); printf("%s\n", line); } } } 
Source Link
pacmaninbw
  • 26.2k
  • 13
  • 47
  • 114

The main program can be simplified by using a function you probably haven't read about yet call fgets. This function reads a line of text at a time. The variable line will contain the new line after the function has been called, you would need to remove the new line before you reverse the input.

int main() { char line[BUFSIZ]; while (fgets(line, BUFSIZ, stdin) != NULL) { if (line[0]) { reverseLine(line); printf("%s\n", line); } } }