#include<stdio.h>
void main()
{
FILE *fp;
char ch;
char source[67];
int count = 1;
clrscr();
puts("enter the file name:");
gets(source);
fp=fopen(source,"r");// read only mode for the source file
if(fp==NULL)
{
puts("unable to open the file:");
getch();
exit();
}
clrscr();
printf("file name:%s",source);
printf("\n line:-%d\t",count);
while((ch=getc(fp))!=EOF)
{
if(ch=='\n')
{
count++;
printf("\nline:-%d\t",count);
}
else
{
printf("%c",ch);
}
}
printf("\n press any key...");
getch();
fclose(fp);
}
Comments
Post a Comment