Next: Handling Files in Up: Whole Lines of Previous: gets

puts

puts writes a string to the output, and follows it with a newline character.

Example: Program which uses gets and puts to double space typed input.


#include <stdio.h>

main()
{       char line[256]; /* Define string sufficiently large to 
                            store a line of input */

        while(gets(line) != NULL)   /* Read line        */
        {        puts(line);        /* Print line       */
                 printf("\n");      /* Print blank line */
        }
}

Note that putchar, printf and puts can be freely used together. So can getchar, scanf and gets.


January 1995