Friday, 23 September 2016

Read text file

/* Read text file */

#include<stdio.h>
int main()
{
FILE *fp;
int ch;

fp=fopen("myfile.txt","r");
if(fp==NULL)
{
printf("Can't find the source file.");
return 1;
}
while(1)
{
ch=fgetc(fp);
if(feof(fp)) break;
printf("%c",ch);
}
fclose(fp);
return 0;
}

No comments:

Post a Comment

Featured post

Will AI Replace Programmers? The Truth Behind the Hype in 2025

Exploring the Future of Coding: Will AI Take Over Software Development or Enhance It?  Will AI Replace Programmers? The Truth Behind the Hyp...