C Program to Read String using gets Function

List of C Programs
List of All Programs

Write C Program to Read String using gets Function

// C Program to Read String using gets Function

//it differs from the scanf as in scanf after the space the string ends with the null character
// here null character is applied only after the size is over and space is also considered as a character


#include <stdio.h>

int main()
{
	char S[50];
	printf("Enter the String :--> ");

	gets(S);

	printf("You Entered :--> %s", S);
	return 0;
}

Output:

Enter the String :--> Code Crucks
You Entered :--> Code Crucks

≪ Previous | Next ≫