Borland C++ reference

gets

raw OCR

Gets a string from stdin.

Defined in header <stdio.h>

Syntax

#include <stdio.h>
char *gets(char *s);

Portability

DOSUNIXWindowsANSI CC++ only
■■■

Remarks

gets collects a string of characters terminated by a new line from the standard input stream stdin and puts it into s. The new line is replaced by a null character (\0) in s.

gets allows input strings to contain certain whitespace characters (spaces, tabs), gets returns when it encounters a new line; everything up to the new line is copied into s.

Return value

On success, gets returns the string argument s; it returns null on end-of-file or error.

See also

Example

#include <stdio.h>

int main (void)

   char string [80];
   printf("Input a string:");
   gets(string) ;
   printf("The string  input was: %s\n", string);
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.