Write a C program for File Operations to read a string from standard input and prints the entered string using fgets() and fputs() function.
#include<stdio.h>
int main()
{
char entered_sentence[200];
fputs("Enter a string: ", stdout); // Demostrating the fputs() is used to print
fgets(entered_sentence, sizeof(entered_sentence), stdin); //Illustrating how the fgets() function reads the input from the standard input
fputs(entered_sentence, stdout); //Printing the string entered by the user.
//printf("The entered string: %s",str);
return 0;
}
Comments
Leave a comment