#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define N 5000
void main()
{
FILE *sfp;
int i;
char buf[N];
if((sfp=fopen("c:\\datafile.txt","r"))==NULL)
{
printf("Source file cannot be opened!\n");
exit(1);
}
i=0;
while(!feof(sfp))
{
buf[i++]=fgetc(sfp);
if(i>=N)
{
printf("buffer not enough!");
exit(1);
}
}
while(--i>=0)
fputc(buf[i],stdout);
fclose(sfp);
getch();
}
#include<stdlib.h>
#include<conio.h>
#define N 5000
void main()
{
FILE *sfp;
int i;
char buf[N];
if((sfp=fopen("c:\\datafile.txt","r"))==NULL)
{
printf("Source file cannot be opened!\n");
exit(1);
}
i=0;
while(!feof(sfp))
{
buf[i++]=fgetc(sfp);
if(i>=N)
{
printf("buffer not enough!");
exit(1);
}
}
while(--i>=0)
fputc(buf[i],stdout);
fclose(sfp);
getch();
}