This post will help you in reading a file line by line...
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
fp=fopen("c:\milan.c","r");
clrscr();
if(fp!=NULL)
{
char line[128];
while(fgets(line,sizeof line,fp)!=NULL)
{
char *nwln=strchr(line,'\n');
if(nwln!=NULL)
*nwln='\0';
printf("%s\n",line);
}
}
getch();
}
No comments:
Post a Comment
Feel free to comment......