Hello Friends,
File Handing in C language is one of the most important topic. The program which written below will make one file and you can write your data as you wanted.
Example:
#include<conio.h>
#include<stdio.h>
void main()
{
FILE *f1; // File pointer variable declared
char c;
printf("Enter Data\n\n");
f1=fopen("DATA","w"); // File DATA created and ready to write
while((c=getchar()) != EOF)
{
putc(c,f1);
}
fclose(f1);
printf("\n\nYour Data in File:\n\n");
f1=fopen("DATA","r") // File will open in read mode
while((c=getc(f1)) !=EOF)
{
printf("%c",c);
}
fclose(f1);
getch();
}
File Handing in C language is one of the most important topic. The program which written below will make one file and you can write your data as you wanted.
Example:
#include<conio.h>
#include<stdio.h>
void main()
{
FILE *f1; // File pointer variable declared
char c;
printf("Enter Data\n\n");
f1=fopen("DATA","w"); // File DATA created and ready to write
while((c=getchar()) != EOF)
{
putc(c,f1);
}
fclose(f1);
printf("\n\nYour Data in File:\n\n");
f1=fopen("DATA","r") // File will open in read mode
while((c=getc(f1)) !=EOF)
{
printf("%c",c);
}
fclose(f1);
getch();
}