首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >C Mingw "ld.exe:无法打开输出文件cipher.exe:权限被拒绝收集器2.exe错误: ld返回%1退出状态“

C Mingw "ld.exe:无法打开输出文件cipher.exe:权限被拒绝收集器2.exe错误: ld返回%1退出状态“
EN

Stack Overflow用户
提问于 2020-11-18 20:48:34
回答 1查看 36关注 0票数 0

首先,我会说我实际上可以编译C语言,至少它对于一个简单的"hello world“是有效的。但是,我无法编译以下.c代码:

代码语言:javascript
运行
复制
#include <stdio.h>
#include <stdlib.h>
#define STRINGSIZE 10

int getLastPosition(char word[])
{
    int cont=0;
    while(cont<STRINGSIZE)
    {
        if(word[cont]=='\0')
        {
            break;
        }
        cont++;
    }
    return cont;
}


void cipher(int key, char *firstChar, char *lastChar)
{
    char *currentChar = NULL;

    currentChar = firstChar;
    while(currentChar<lastChar)
    {
        *currentChar += key;
        currentChar++;
    }

    printf("\nThe ciphered word is:  ");

    currentChar = firstChar;
    while(currentChar<lastChar)
    {
        printf("%c", *currentChar);
        currentChar++;
    }

}


int main()
{
    char word[STRINGSIZE];
    char *firstChar = NULL;
    char *lastChar = NULL;
    int key;

    printf("Enter a word to cipher (max 10 chars)> \n");
    scanf("%s",word);

    printf("Choose a number to cipher the word > \n");
    scanf("%d",&key);

    firstChar = &word[0];
    lastChar = firstChar + getLastPosition(word);

    cipher(key, firstChar, lastChar);
}

我没有阻止输出文件的杀毒软件。但是,我从任务管理器中看到cipher.exe确实是作为一个进程加载的,但是终止任务并重新运行c代码对我来说是行不通的。有人能帮上忙吗?

EN

回答 1

Stack Overflow用户

发布于 2020-11-19 21:39:31

你真的应该发布构建过程的输出。

但从您所说的情况来看,您似乎无法覆盖输出文件。基本上,你需要确保你可以覆盖它:

  • 确保输出文件未被锁定或当前正在运行,通过删除它可以轻松地测试这一点。如果不起作用,你可以在重新启动后重试。
  • 确保你的用户有权限在该位置写入文件(使用某些IDE或构建系统时,请检查文件夹permissions).
  • Especially当在包含特殊字符(如空格)或UNC路径(以\\\\开头)的位置构建时,可能会出现问题。因此要避免在路径中使用特殊位置和特殊字符。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64893469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档