C examples for File:Standard Device
Use fgets() function to read from console/stdin
#include <stdio.h> #define MAXLEN 10/* ww w . ja v a2 s.com*/ int main( void ) { char buffer[MAXLEN]; puts("Enter text a line at a time; enter a blank to exit."); while (1) { fgets(buffer, MAXLEN, stdin); if (buffer[0] == '\n') break; puts(buffer); } return 0; }