将一个文本文件的内容按倒序打印出来

匿名网友 匿名网友 发布于: 2015-08-30 00:00:00
阅读 99 收藏 0 点赞 0 评论 0

解:   #include <stdio.h>
main()
#define m 20
{
char str1[m];
int i;
FILE  *fp1;
if((fp1=fopen(“file2.c”,”r”))==NULL)
{
printf(“cannot open the filen”);
exit(0);
}
i=0;
While(!feof(fp1))
{
strl[i]=fgetc(fp1);
i++;
}
while(i!=0)
{
i–;
Putchar(str1[i]);
}
fclose(fp1);
}

解:   #include <stdio.h>

main()

#define m 20

{

char str1[m];

int i;

FILE  *fp1;

if((fp1=fopen(“file2.c”,”r”))==NULL)

{

printf(“cannot open the filen”);

exit(0);

}

i=0;

While(!feof(fp1))

{

strl[i]=fgetc(fp1);

i++;

}

while(i!=0)

{

i–;

Putchar(str1[i]);

}

fclose(fp1);

}

评论列表
文章目录