home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sams Teach Yourself C in 21 Days (6th Edition)
/
STYC216E.ISO
/
mac
/
Examples
/
Day14
/
getchar2.c
< prev
next >
Wrap
C/C++ Source or Header
|
2002-05-05
|
305b
|
22 lines
/* Using getchar() to input strings. */
#include <stdio.h>
#define MAX 80
int main( void )
{
char ch, buffer[MAX+1];
int x = 0;
while ((ch = getchar()) != '\n' && x < MAX)
buffer[x++] = ch;
buffer[x] = '\0';
printf("%s\n", buffer);
return 0;
}