Read a character array from stdin.
This function is compatible with the following targets:
|
|
#include <stdio.h>
char *gets(char *s);Parameters:
Parameters for this facility are:
gets() returns s if it is successful and returns a null pointer if it fails.
"Wide Character and Byte Character Stream Orientation"
Example of gets() usage.:#include <stdio.h>
#include <string.h>
int main(void)
{
char buf[100];
printf("Enter text lines to echo.\n");
printf("Enter an empty line to quit.\n");
// read character strings from the console
// until an empty line is read
while (strlen(gets(buf)) > 0)
puts(buf); // puts() appends a newline to its output
printf("Done!\n");
return 0;
}
Output:
Enter text lines to echo.
Enter an empty line to quit.
I'm experiencing deja-vu
I'm experiencing deja-vu
Now go to work
Now go to work
Done!
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 16, 2000