Sunday, March 22, 2015

Read and print a line of text

Script

#include <stdio.h>

main()
{
        char text[100];
        printf("\n");
        printf("Enter a line of text:            ");
        scanf(" %[^\n]", text);
        printf("\n");
        printf("You entered the following text:  ");
        printf("%s", text);
        printf("\n\n");
}


Execution


Enter a line of text:                     Gundappa Viswanath played 91 Test matches for India and scored 6080 runs.

You entered the following text:  Gundappa Viswanath played 91 Test matches for India and scored 6080 runs.





Enter a line of text:                     There's an aura about Sachin Tendulkar in India and around the cricketing globe that is unmatched by anyone else.

You entered the following text:  There's an aura about Sachin Tendulkar in India and around the cricketing globe that is unmatched by anyone else.

No comments:

Post a Comment