Tuesday, November 27, 2012

Writing and reading Data from text FILE using C language


#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
FILE *f,*f1;
char c;
clrscr();
f=fopen("balaram.txt","w");
if (f==NULL)
{
printf("Cannot open file");
exit(1);
}
printf("write data and to stop press '.':");
while(c!='.')
{
c=getche();
fputc(c,f);
}
fclose(f);
printf("\n contents read:");
f1=fopen("balaram.txt","r");
while(!feof(f1))
printf("%c",getc(f1));
}

No comments:

Post a Comment

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...