Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>fgets</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
fgets

Usage

   #include <stdio.h>
   char *fgets(char *str,int n,FILE *fp);

   ANSI

Description

   Reads characters from stream fp into the string pointed to by str. The
   integer argument n indicates the maximum number of characters that the
   buffer str can store. Reading stops when a newline is read, end-of-file
   is encountered, a read error occurs, or n-1 characters were read.
   Newlines are included in the string. The string read is terminated
   with a 0.

Example 

   #include <stdio.h>
   #include <stdlib.h>

   int main()
   {
       char buffer[255];
       int buflen;
       char *result;
       buflen = 255;
       fputs("Enter line of data\n",stdout);
       result = fgets(buffer,buflen,stdin);
       if(!result) {

           printf("\nEOF or ERROR\n");
       }
       else fputs(buffer,stdout);
       return EXIT_SUCCESS;
   }

Return Value

   String str if successful. If no characters have been read into str and a
   read error or EOF is encountered, NULL is returned and the string pointed
   to by str is unchanged. If a read error occurs, NULL is returned and str
   contains garbage.

See Also

   fputs, gets, puts



See Also: fputs gets puts

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