/*WAP to open and close a file*/
#include#include void main() { char ch; int i; clrscr(); FILE *fptr; fptr=fopen("file1.dat","w"); printf("\nenter 5 character:\n"); for(i=0;i<=5;i++) { ch=getchar(); fputc(ch,fptr); } fclose(fptr); printf("\nreading form file & print on screen\n"); fptr=fopen("file1.dat","r"); while(!feof(fptr)) { ch=getc(fptr); putchar(ch); } fclose(fptr); getch(); }
No comments:
Post a Comment