#include<stdio.h>
#include<conio.h>
void main()
{
char name[50];
FILE *fptr;
fptr=fopen("D:\\sentence.txt","w");
printf("Enter name: ");
gets(name);
fprintf(fptr,"%s",name);
fclose(fptr);
getch();
}
OUTPUT:
Enter name: I am Nepali
If the file name sentence.txt inside D drive already exists, its contents are overwritten with "I am Nepali" inside it. If does not exist, it will be created.
No comments:
Post a Comment