Question:30
Write a C program to read a file line by line, display reverse of lines
Sol:
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
FILE *fp;
char buff[255];
fp = fopen("test11.txt", "r");
if(fp==NULL)
{
printf("Unable to open the file\n");
return(0);
}
while(1)
{
fgets(buff, 255,fp); //reads line by line
if(feof(fp))
{
printf("\n\n\nend of file");
break;
}
printf("%s\n", strrev(buff ));
}
fclose(fp);
getch();
return(0);
}




