#include <stdio.h>
#include <string.h>
int main()
{
FILE *fp;
char str[80];
fp = fopen("test.txt", "w+");
printf("Enter your message:");
gets(str);
fprintf(fp, "%s",str);
printf("Your message is written in test.txt file.");
fclose(fp);
//File validation is to be performed...
return 0;
}
Output of program
Enter your message:hello student
Your message is written in test.txt file.
#include <string.h>
int main()
{
FILE *fp;
char str[80];
fp = fopen("test.txt", "w+");
printf("Enter your message:");
gets(str);
fprintf(fp, "%s",str);
printf("Your message is written in test.txt file.");
fclose(fp);
//File validation is to be performed...
return 0;
}
Output of program
Enter your message:hello student
Your message is written in test.txt file.
No comments:
Post a Comment