鱼C论坛

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

谁帮我改一下这段代码错误

[复制链接]
发表于 2014-6-17 07:59:16 | 显示全部楼层 |阅读模式
1鱼币
本帖最后由 风之残月 于 2014-11-10 10:13 编辑

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

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

          printf("请输入需要合成的图片和文件的名称: \n");
          printf("图片: ");
          scanf("%s", pic_name);
          printf("文件: ");
          scanf("%s",file_name);
          printf("生成为: ");
          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);
                   fpuc(ch,f_finish);
          }
      fclose(f_file);
          fclose(f_finish);

          system("pause")

}


最佳答案

查看完整内容

f_file 没有定义 ,应该 FILE *f_pic, *f_finish, *f_file; 或换行定义 FILE *f_file; fpuc(ch,f_finish); 这句 "fputc" 写成了 "fpuc" system("pause") 没有以 ; 结尾
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-6-17 07:59:17 | 显示全部楼层
f_file 没有定义 ,应该 FILE *f_pic, *f_finish, *f_file; 或换行定义 FILE *f_file;
fpuc(ch,f_finish); 这句 "fputc" 写成了 "fpuc"
system("pause") 没有以 ; 结尾
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2014-6-17 22:17:21 | 显示全部楼层

那个你直接在原文上帮我改发一下吧 谢谢你了啊 新手!
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-6-18 08:10:32 | 显示全部楼层
  1. #include<stdio.h>
  2. #include<stdlib.h>

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

  7.         printf("请输入需要合成的图片和文件的名称: \n");
  8.         printf("图片: ");
  9.         scanf("%s", pic_name);
  10.         printf("文件: ");
  11.         scanf("%s",file_name);
  12.         printf("生成为: ");
  13.         scanf("%s",finish_name);

  14.         if(!(f_pic = fopen(pic_name,"rb")))
  15.         {
  16.                 printf("Cannot open the picture %s !",pic_name);
  17.                 return;
  18.         }
  19.         if(!(f_file =fopen(file_name,"rb")))
  20.         {               
  21.                 printf("Cannot open the file %s !",file_name);
  22.                 return;
  23.                
  24.         }
  25.         if(!(f_finish = fopen(finish_name,"wb")))
  26.         {               
  27.                 printf("Cannot open the file %s!",finish_name);
  28.                 return;
  29.               
  30.         }
  31.          
  32.         while(!(feof(f_pic)))
  33.         {
  34.                ch = fgetc(f_pic);
  35.                fputc(ch,f_finish);
  36.         }
  37.         fclose(f_pic);

  38.         while(!(feof(f_file)))
  39.         {
  40.                ch =fgetc(f_file);
  41.                fputc(ch,f_finish);
  42.         }
  43.         fclose(f_file);
  44.         fclose(f_finish);

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

使用道具 举报

发表于 2014-6-18 20:08:54 | 显示全部楼层
很不错,很值得学习和借鉴
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-7-27 15:32:22 | 显示全部楼层
#include<stdio.h>
#include<stdlib.h>

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

        printf("请输入需要合成的图片和文件的名称: \n");
        printf("图片: ");
        scanf("%s", pic_name);
        printf("文件: ");
        scanf("%s",file_name);
        printf("生成为: ");
        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;
              
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-4 09:31

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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