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 argument 'string'. A NULL pointer indicates
an error or end-of-file condition. Use ferror() or
feof() to determine whether an error or eof occurred.
Notes: fgets() is like gets(), but fgets() 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);
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster