文件里面有1234.jpg怎么拷贝不了

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#pragma warning (disable:4996)
int main()
{
    FILE*p = fopen("1234.jpg", "rb");
    if (NULL == p)
    {
        perror("");
        return -1;
    }
    FILE*a = fopen("haha1234.jpg", "wb");
    if (NULL == a)
    {
        perror("");
        return -1;
    }
    while (1)
    {
        char ch = 0;
        ch = fgetc(p);
        if (feof(p))
        {
            break;
        }
        fputc(ch, a);
    }
    fclose(p);
    fclose(a);

}

 

写完整路径试试

FILE*p = fopen("1234.jpg", "rb");
FILE*a = fopen("haha1234.jpg", "wb");

文件最好用绝对路径,我测试了一下用绝对路径代码是可以的

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632