Code for PROGRAM TO READ A LINE OF TEXT FROM TERMINAL in C Programming
#include <stdio.h>
main( )
{
char line[81], character;
int c;
c = 0;
printf("Enter text. Press <Return> at end\n");
do
{
character = getchar();
line[c] = character;
c++;
}
while(character != '\n');
c = c - 1;
line[c] = '\0';
printf("\n%s\n", line);
}
Output
Enter text. Press <Return> at end
Programming in C is interesting.
Programming in C is interesting.
Enter text. Press <Return> at end
National Centre for Expert Systems, Hyderabad.
National Centre for Expert Systems, Hyderabad.