Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>gets() read a line from 'stdin'</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 gets()                  Read a Line from 'Stdin'

 #include   <stdio.h>

 char       *gets(buffer);
 char       *buffer;                     Storage location for input string

    gets() reads a string from the standard input 'stdin' and stores it
    in 'buffer'.  The string consists of all characters up to and
    including the first new-line character ('\n').  The new-line
    character is replaced with a null character ('\0').

    Returns:    The string.  An error or an end-of-file condition is
                indicated by a NULL pointer; ferror() or feof() can be
                used to determine which of these conditions occurred.

      Notes:    fgets() is like gets(), but retains the new-line
                character.

   -------------------------------- Example ---------------------------------

    The following statements get a string from 'stdin' and print it to
    the screen.

           #include <stdio.h>

           char buffr[80];
           char *rslt;

           main()
           {
               if (!feof(rslt = gets(buffr)))
                     printf("\n%s",rslt);
           }



See Also: fgets() fputs() puts() feof() ferror()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson