Hi Friend, As i had told you, here is a general code, that can display a ASCII format Text file perfectly as same as it can be viewed in any formatted text editor like wordpad.
#include<stdio.h> // For FILE operations
#include<conio.h> // For putchar() function
void main()
{
FILE *pFile;
int c;
pFile = fopen("test.txt","r");
if(pFile == NULL)
{
printf("Error opening file");
exit(1);
}
while(c != EOF)
{
c = fgetc(pFile);
putchar(c);
}
getch();
}
</conio.h></stdio.h>
See, it wasn't difficult at all, now the only thing you need to remember before getting perfectly fine display is:
Maximum Columns in a single Row must to 80, since in dos text mode, only 80 columns are there.
Hope it will help you. :-)
Regards
Tushar Srivastava :-)