/////// readline.C /////// #include //const int SIZE = 100; const int SIZE = 10; // len is the length of the array s int readline(char s[], int len) { char c = '\0'; int i = 0; len --; // leaving room at the end while ( i < len && cin.get(c) && c != '\n') s[i++] = c; if (c == '\n') s[i++] = c; s[i] = '\0'; // string terminator return(i); } int main() { char line[SIZE]; int n; while ((n = readline(line, SIZE)) > 0) cout << "n = " << n << "\t line= " << line; return(0); }