Exp3: WAP to write a sentence or text till press enter key. And read saved sentence or text from file.

 

#include<stdio.h>

#include<conio.h>

#include<ctype.h>

void main()

{

FILE *f;

char ch;

clrscr();

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

while(toascii(ch=getche()) != 13)

fputc(ch,f);

fclose(f);

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

printf("\n");

while((ch=fgetc(f))!= EOF)

printf("%c",ch);

fclose(f);

getch();

}

 

Back - C Language Notes By Vivek Sir email: vivekdubey22@gmail.com (w) 9826424484

C Language Video