Write a C program for File Operations to read a string from standard input and prints the entered string using fgets() and fputs() function.
Runtime Input :
Hai
Output :
Hai
#include<stdio.h>
#include<conio.h>
void main() {
FILE* fp;
char text[300];
fp = fopen("myfile2.txt", "w");
fputs("hello c programming", fp);
printf("%s", fgets(text, 200, fp));
fclose(fp);
getch();
}
Comments
Leave a comment