鱼C论坛

 找回密码
 立即注册
查看: 4641|回复: 7

求助关于图片文件合成器

[复制链接]
发表于 2011-6-3 16:08:05 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
   
        我看了你的C语言教学第十一章文件操作的视频后其中有一个是关于制作图片文件合成器的那个小程序。我安装屏幕上的代码打了,结果执行后输入图片名称,文件名称,生成文件名称 之后再按回车没有反应  没有生成新文件 请问这是怎么回事?  
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"


main()
{
    FILE *f_pic,*f_file,*f_finish;
    char ch,pic_name[20],file_name[20],finish_name[20];
    printf("please input picture name:\n");
    printf("picture:");
    scanf("%s",pic_name);
    printf("file:");
    scanf("%s",file_name);
    printf("new file:");
    scanf("%s",finish_name);

    if(!(f_pic =fopen(pic_name,"rb")))
        {
            printf("cannot open the picture %s !",pic_name);
            return;
         }
      if (!(f_file =fopen(file_name,"rb")))
           {
            printf("cannot open the file %s !",file_name);
            return;
            }
         if (!(f_finish =fopen(finish_name,"wb")))
           {
            printf("cannot open the file %s !",finish_name);
            return;
            }
       while(!(feof(f_pic)))
       {
            ch =fgetc(f_pic);
            fputc(ch,f_finish);
        }
        fclose(f_pic);
       while(!(feof(f_file)))
       {
            ch = fgetc(f_file);
            fputc(ch,f_finish);
        }
        fclose(f_file);
        fclose(f_finish);
    system("pause");

    getch();
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-6-3 22:00:14 | 显示全部楼层
还没学到这来,爱莫能助
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-6-3 22:05:31 | 显示全部楼层
代码没问题,可以生成
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-6-4 12:41:23 From FishC Mobile | 显示全部楼层
查查会不会让杀毒软件和谐了。代码没错。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-6-19 08:31:34 | 显示全部楼层
这个干吗用的
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2012-6-17 22:33:28 | 显示全部楼层
运行有警告,但我也不会处理!! 可以肯定,程序能运行,且能生成文件!!生成文件需要条件:
就是两个文件和程序都要在同一目录下!!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2013-6-9 14:17:57 | 显示全部楼层

#include <stdio.h>
#include <stdlib.h>

void main()
{
      FILE *f_file, *f_pic, *f_finish;
      char ch, pic_name[20], file_name[20], finish_name[20];

      printf("Please enter in the name of the pictures, documents to synthesis: \n");
      printf("pictures: ");
      scanf("%s", pic_name);
      printf("document: ");
      scanf("%s", file_name);
      printf("finish: ");
      scanf("%s", finish_name);

      if( !(f_pic = fopen(pic_name, "rb")))
      {
            printf("Cannot open the ficture %s!\n", pic_name);
            exit(0);   /*终止程序 */
      }
      if( !(f_file = fopen(file_name, "rb")))
      {
            printf("Cannot open the file %s!\n", file_name);
            exit(0);   /*终止程序 */
      }
      if( !(f_finish = fopen(finish_name, "wb")))
      {
            printf("Cannot open the file %s!\n", finish_name);
            exit(0);    /* 终止程序 */
      }

      while( !feof(f_pic) )
      {
            ch = fgetc(f_pic);
            fputc(ch, f_finish);
      }
      fclose(f_pic);

      while( !feof(f_file) )
      {
            ch = fgetc(f_file);
            fputc(ch, f_finish);
      }
      fclose(f_file);
      fclose(f_finish);
}



这是图片合成器的代码,但是我照视频上那样弄了,但是就是没办法生成。

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2013-6-9 15:20:54 | 显示全部楼层
有没有写后缀名?设置文件后缀名可见??
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-20 08:49

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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