C examples for String:String Console Input
Read a line and stop at \n
#include <stdio.h> #define MAXLINE 1000/*from w w w.ja v a 2 s . com*/ int main(void) { char line[MAXLINE]; int c, i; i = 0; while (i < MAXLINE - 1) { if ((c=getchar()) == EOF) break; line[i++] = c; if (c == '\n') break; } line[i] = '\0'; printf("%s\n", line); return 0; }