- 帖子
- 3151
- 积分
- 6455
- 技术
- 317
- 捐助
- 70
- 注册时间
- 2008-8-3
|
回复 9# jyswjjgdwtdtj
年轻人C语言没接触过吗
本以为吕布已经天下无敌了,没想到有人比他还要勇猛,这是谁的部将?
include <stdio.h>
include <stdlib.h>
int main(int argc, char *argv[] )
{
FILE *fp = fopen("tmp.txt", "rb");
char c;
int size;
int offset = -1;
//定位到文件末尾
fseek( fp, 0, SEEK_END );
//末尾的offset
size = ftell(fp);
int count = 0;
//只捕获除换行符以外的倒数3个字符
while ( count < 3 && abs(offset) <= size )
{
fseek( fp, offset--, SEEK_END );
c = getc( fp );
if ( c != 13 && c != 10 )
{
count++;
printf("%c\n", c);
}
}
return 0;
} |
|
-
1
评分人数
-
|