Exp4: WAP to read and write a integer number 10 using file handling.

 

#include<stdio.h>

#include<conio.h>

#include<ctype.h>

void main()

{

FILE *f;

int intdata;

clrscr();

f = fopen("c:\\users\\dr\\c_prog\\temp2.dat","w");

fprintf(f,"%d",10);

fclose(f);

f = fopen("c:\\users\\dr\\c_prog\\temp2.dat","r");

printf("\n");

fscanf(f,"%d",&intdata);

printf("%d",intdata);

fclose(f);

getch();

}