有没有办法将字符串变量传递给c中的remove()

1 c io file-io file

好的,这就是我正在使用的功能remove()

int fmove(const char * filepth, const char * destpth)
{
    FILE * fp;
    fp = fopen(filepth, "r+");

    FILE * fpdest;
    fpdest = fopen(destpth, "w");

    if ((fp != NULL) && (fpdest != NULL))
    {
        char fpdata[999];
        fgets(fpdata, 999, fp);
        fputs(fpdata, fpdest);

        remove(filepth);
    } else
    {
        prtmessage("ERROR", "Cannot move file!");
        return 1;
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

remove()返回-1。我知道数组返回它们的指针(我说得对吗?),但是有没有办法将字符串传递到filepathto remove()

Vla*_*cow 6

来自C标准

如果文件打开,则删除函数的行为是实现定义的。

您需要在调用之前关闭该文件remove()