标题:如何切掉文件头?
只看楼主
zuozuo01
Rank: 2
等 级:论坛游民
帖 子:4
专家分:20
注 册:2018-3-10
结帖率:50%
已结贴  问题点数:20 回复次数:1 
如何切掉文件头?
下面是文件互相拷贝的例子,我想把文件从偏移0x80开始起切掉,应该在哪里增加什么语句?
谢谢!

#include <stdio.h>
#include <stdlib.h>
#define MAXLEN 1024

int main(int argc, char *argv[])
{
    if( argc < 3 )
    {
        printf("usage: %s %s/n", argv[0], "infile outfile");
        exit(1);
    }
    FILE * outfile, *infile;
    outfile = fopen(argv[2], "wb" );
    infile = fopen(argv[1], "rb");
    unsigned char buf[MAXLEN];

    if( outfile == NULL || infile == NULL )
    {
        printf("%s, %s",argv[1],"not exit/n");
        exit(1);
    }   
    int rc;
    while( (rc = fread(buf,sizeof(unsigned char), MAXLEN,infile)) != 0 )
    {
        fwrite( buf, sizeof( unsigned char ), rc, outfile );
}
fclose(infile);
fclose(outfile);
system("PAUSE");
return 0;
}
搜索更多相关主题的帖子: 文件 int char exit unsigned 
2018-03-10 11:16
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册:2014-5-20
得分:20 
fseek()
2018-03-10 11:41



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-485133-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.822722 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved