In this program, we will read a string with spaces using gets() function. The puts() function is used to display the entered string. The function gets() : Reads characters from the standard input and stores them as a string. It stops when either the newline character is read or when the end-of-file is reached, whichever comes first. The function puts() : prints characters from the standard output. The scanf() function reads a single word (without spaces), however gets() reads a line of string (with spaces)
#include<stdio.h>
int main()
{
char name[30];
printf("Enter the line of text: ");
gets(name);
printf("\nYou entered the text....\n");
puts(name);
return 0;
}
Enter the line of text: Welcome to the world of C Programming!
You entered the text....
Welcome to the world of C Programming!