C代码无法运行,并显示一些令人困惑的内容。

huangapple go评论63阅读模式
英文:

C code is not running and showing something confusing

问题

PS C:\Users\main> gcc Untitled-1.c
PS C:\Users\main> ./answer
./answer:未将"./answer"识别为cmdlet、函数、脚本文件或可操作的程序的名称。请检查名称的拼写,或者如果包括了路径,请验证路径是否正确,然后重试。
在行:1字符:1

  • ./answer
  •   + CategoryInfo          : ObjectNotFound: (./answer:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

VS Code持续显示这个。起初它显示了致命错误和同时出现的文本。
我解决了致命错误,但仍然没有显示输出。我需要尽快解决这个问题。
我尝试更改文件编译的路径。这解决了一个致命错误,但不能解决这个问题。

英文:
PS C:\Users\main> gcc Untitled-1.c
PS C:\Users\main> ./answer
./answer : The term './answer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check 
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ ./answer
+ ~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (./answer:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

VS code is continususly showing me this. At first it showed fatal error and this text at the same time.
I resolved the fatal error but it is still not showing the output. I need to get this threw early.

I tried to change the path of compilation of file. that resolves one fatal error but cannot got resolved this.

答案1

得分: 2

当你编译时没有指定输出文件时,在Windows上默认的输出文件是 a.exe(在Linux系统上默认为 a.out)。

所以你的第一个命令是编译 Untitled-1.c 并生成了程序 a.exe。但是你尝试运行 answer.exe,但它并不存在。

你可能想要修改你的构建步骤为:

gcc -o answer.exe Untitled-1.c

这可能是在 tasks.json 或者你的 makefile 文件中完成的。

英文:

When you compile without specifying an output file, the default output will be a.exe on Windows (and a.out on Linux flavors).

So your first command is compiling Untitled-1.c and producing program a.exe. But you are attempting to run answer.exe, which does not exist.

You probably want to modify your build step to be:

gcc -o answer.exe Untitled-1.c

This is probably done in either tasks.json or your makefile

huangapple
  • 本文由 发表于 2023年6月5日 22:07:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76407269.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定