- 论坛徽章:
- 0
|
#include "stdio.h"
#include "string.h"
main(int argc,char *argv[] )
{ int i=0;
FILE *fp;
void *buf;
FILE *wr;
long int j=0;
if((fp=fopen("f:\\turboc2\\program\\test1.txt","r" )==NULL)
{
printf("Cannot open file" ;
exit(1);
}
wr=fopen("f:\\turboc2\\program\\file.txt","w" ;
for(i=0;i<2;i++)
{
fseek(fp,ftell(fp),SEEK_SET);
fread(buf,sizeof(char),100,fp);
/*fwrite(buf,524288,100,wr); */
printf("%s",buf);
}
fclose(fp);
fclose(wr);
}
输出:
Frame 1 (283 bytes on wire, 283 bytes captured)
Arrival Time: May 20, 2004 14:20:55.158823000
1355-03 Time delta from previous packet: 0.000000000 seconds
Time since reference or first frame: 0.001355-030000000 seconds
Frame Number: 1
Packet Length: 283 bytes
Capture Length: 283 bytes
Ether1355-03net II, Src: 00:04:9b:1a:c0:00, Dst: 00:09:b6:16:48:ca
Destination: 00:09:b6:16:48:ca (Cisco_16:1355-0348:ca)
Source: 00:04:9b:1a:c0:00 (Cisco_1a:c0:00)
Type: IP (0x0800)
Internet Protocol, Src A1355-03ddr: 211.136.70.90 (211.136.70.90), Dst Addr: 211.136.70.13 (211.136.70.13)
Version: 4
Heade1355-03r length: 20 bytes
Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)
01355-03
最后的结果是多读入了一个不知道哪里来的字符串"01355-03",这个字符串文本文件中并不存在,这是为什么呢? |
|