Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdio.h>
    char *gets( char *buf );
    #include <stdio.h>
    wchar_t *_getws( wchar_t *buf );

Description:
    The gets function gets a string of characters from the file designated
    by  stdin and stores them in the array pointed to by buf until
    end-of-file is encountered or a new-line character is read.  Any
    new-line character is discarded, and a null character is placed
    immediately after the last character read into the array.

    The _getws function is identical to gets except that it gets a string of
    multibyte characters (if present) from the input stream pointed to by
     stdin, converts them to wide characters, and stores them in the
    wide-character array pointed to by buf until end-of-file is encountered
    or a wide-character new-line character is read.

    It is recommended that  fgets be used instead of gets because data
    beyond the array buf will be destroyed if a new-line character is not
    read from the input stream  stdin before the end of the array buf is
    reached.

    A common programming error is to assume the presence of a new-line
    character in every string that is read into the array.  A new-line
    character may not appear as the last character in a file, just before
    end-of-file.

Returns:
    The gets function returns buf if successful.  NULL is returned if
    end-of-file is encountered, or if a read error occurs.  When an error
    has occurred,  errno contains a value indicating the type of error that
    has been detected.

Example:
    #include <stdio.h>

    void main()
      {
        char buffer[80];

        while( gets( buffer ) != NULL )
          puts( buffer );
      }

Classification:
    gets is ANSI, _getws is not ANSI

Systems:
     gets - All, Netware

    _getws - All

See Also:
    fgetc, fgetchar, fgets, fopen, getc, getchar, ungetc

See Also:

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