#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char* argv[])
{
FILE * fp = NULL;
char c = '0';
int i;
int file_size = 0;
fp = fopen("student.c","r");
if(fp == NULL)
{
printf("open file error!\n");
exit(EXIT_FAILURE);
}
fseek(fp,0,SEEK_END);
file_size = ftell(fp);
for(i = 1;i <= file_size;i++)
{
fseek(fp,-i,SEEK_END);
c = getc(fp);
printf("%c",c);
fflush(stdout);
usleep(10000);
}
printf("\n");
fclose(fp);
return 0;
}
C语言打开一个文件(有内容),倒序打印出文件中的内容
最新推荐文章于 2024-01-23 21:25:35 发布