home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C by Discovery (4th Edition)
/
C_By_Discovery_4th_Edition.tar
/
C_By_Discovery_4th_Edition
/
_DISK_
/
ch5
/
strngio2.c
< prev
next >
Wrap
C/C++ Source or Header
|
2005-06-16
|
931b
|
30 lines
/* strngio2.c
*
* Synopsis - Prompts for and accepts a line of text as input
* from standard input with the standard library
* function fgets(). Echoes the line to standard
* output with printf().
*
* Objective - To illustrate string input with fgets().
*/
/* Include Files */
#include <stdio.h> /* Note 1 */
/* Constant Definitions */
#define BUF_SIZE 512
int main( void )
{
char inputarray[BUF_SIZE]; /* Note 2 */
char *inputptr;
printf( "Enter a line of text.\n> " );
inputptr = fgets( inputarray, BUF_SIZE, stdin ); /* Note 3 */
if ( inputptr != NULL ) /* Note 4 */
printf( inputptr ); /* Note 5 */
else
printf( "error in input\n" );
return 0;
}