Write a program to read a line of text containing a series of words from the terminal.
#include <stdio.h>
void main( )
{
char line[81], character;
int c;
c = 0;
printf("Enter text. Pressat end\n");
do
{
character = getchar();
line[c] = character;
c++;
}
while(character != '\n');
c = c - 1;
line[c] = '\0';
printf("%s\n", line);
getch();
}
OUTPUT
Enter text. Pressat end
Programming in C is interesting.
Programming in C is interesting.
Enter text. Pressat end
National Centre for Expert System, Hyderabad.
National Centre for Expert System, Hyderabad.
#include <stdio.h>
void main( )
{
char line[81], character;
int c;
c = 0;
printf("Enter text. Press
do
{
character = getchar();
line[c] = character;
c++;
}
while(character != '\n');
c = c - 1;
line[c] = '\0';
printf("%s\n", line);
getch();
}
OUTPUT
Enter text. Press
Programming in C is interesting.
Programming in C is interesting.
Enter text. Press
National Centre for Expert System, Hyderabad.
National Centre for Expert System, Hyderabad.
No comments:
Post a Comment