鱼C论坛

 找回密码
 立即注册
查看: 3278|回复: 5

按小甲鱼老师把图片和pdf合成一个打开pdf会提示文件被破坏

[复制链接]
发表于 2012-5-17 11:51:19 | 显示全部楼层 |阅读模式
1鱼币
#include <stdio.h>
#include <stdlib.h>
void main()
{
    char ch,fromfile[40],tofile[40],finalfile[40];
    FILE *fp1,*fp2,*fp;
    printf("please input the filename you want to copy from:");
    scanf("%s",fromfile);
    if (!(fp1=fopen(fromfile,"rb")))
    {
        printf("illegal input,cann't find!");
        exit(0);
    }
    printf("please input the filename you want to copy to:");
    scanf("%s",tofile);
    if (!(fp2=fopen(tofile,"rb")))
    {
        printf("illegal input,cann't find!");
        exit(0);
    }
    printf("please input the final filename you want to define:");
    scanf("%s",finalfile);
    fp=fopen(finalfile,"wb");
    while (!feof(fp2))
    {
        ch=fgetc(fp2);
        fputc(ch,fp);
        
    }
    fclose(fp2);
    while (!feof(fp1))
    {
        ch=fgetc(fp1);
        fputc(ch,fp);
        
    }
    fclose(fp1);
    fclose(fp);
    system("pause");
}
后缀改成pdf文件就会提示文件被破坏或者就打不开。

最佳答案

查看完整内容

pdf ? 先将其压缩成rar文件吧
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-5-17 11:51:20 | 显示全部楼层
pdf ? 先将其压缩成rar文件吧
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2012-5-17 12:16:13 | 显示全部楼层
//只是合并顺序反了,jpg文件放在前,rar文件放在后面。并且貌似不能合并其他类型的文件
#include <stdio.h>
#include <stdlib.h>
void main()
{
    char ch,fromfile[40],tofile[40],finalfile[40];
    FILE *fp1,*fp2,*fp;

    printf("please input the filename you want to copy from:");
    scanf("%s",fromfile);
    if (!(fp1=fopen(fromfile,"rb")))
    {
        printf("illegal input,cann't find!");
        exit(0);
    }

    printf("please input the filename you want to copy to:");
    scanf("%s",tofile);
    if (!(fp2=fopen(tofile,"rb")))
    {
        printf("illegal input,cann't find!");
        exit(0);
    }

    printf("please input the final filename you want to define:");
    scanf("%s",finalfile);
    fp=fopen(finalfile,"wb");

    while (!feof(fp1))
    {
        ch=fgetc(fp1);
        fputc(ch,fp);
        
    }
    fclose(fp1);
    while (!feof(fp2))
    {
        ch=fgetc(fp2);
        fputc(ch,fp);
        
    }
    fclose(fp2);
    fclose(fp);

    system("pause");
}
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2012-5-17 13:04:42 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2012-5-17 13:05:15 | 显示全部楼层
hxs554f 发表于 2012-5-17 12:16
//只是合并顺序反了,jpg文件放在前,rar文件放在后面。并且貌似不能合并其他类型的文件
#include
#inclu ...

这样jpg的就打不开了
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2012-5-25 14:04:07 | 显示全部楼层
嗯,RAR吧,专门支持这个格式的
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-11-4 08:58

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表