回复 9楼 aneeg
由于汉字比较多,一个字节仅能表示256个,所以一个字节不行

如果你爱C语言,请你爱指针; 如果你爱指针,请你爱指针的指针;
2015-02-11 20:53
2015-02-11 21:32

2015-02-11 23:27
2015-02-12 01:58
2015-02-12 02:00

2015-02-12 10:07
程序代码:#include <stdio.h>
#include <stdlib.h>
#define CNTL_Z '\032' /* DOS 文本文件中的文件结尾标记 这个有吗?*/
#define SLEN 50
int main (void)
{
char file[SLEN];
char ch,cc[3]={0};//增加一个显示汉字的字符数组缓冲
FILE *fp;
long count, last;
puts ("Enter the name of the file to be processed : ");
gets(file);
if ((fp = fopen(file, "rb")) == NULL)
{ /* 只读和二进制模式 */
printf ("reverse can't open %s \n",file);
exit(1);
}
fseek(fp,0L, SEEK_END); /* 定位文件结尾处 */
last = ftell(fp);
for (count = 1L; count <= last; count++)
{
fseek(fp,-count,SEEK_END); /* 回退 */
ch = getc(fp);
/* 针对 DOS, 在 UNIX 下也可工作 */
// if (ch != CNTL_Z && ch != '\r') 13 10是回车换行符号,不论前后都执行同样操作
if(ch>0)
{
putchar(ch);//显示普通asc字符,同时清除汉字显示缓冲
cc[1]=0;
}
else
{
if(cc[1]!=0)
{
cc[0]=ch;
printf("%s",cc);//显示汉字
cc[1]=0;
}
else
cc[1]=ch;
}
}
putchar('\n');
fclose(fp);
return 0;
}

2015-02-12 11:07
2015-02-12 13:44
2015-02-12 13:45

2015-02-12 14:31