为什么在Windows C编程中获得“ a.exe”而不是“ a.out”

use*_*652 0 c compilation

当我通过cc hello_world.c在“ hello_world.c”下面进行编译时,
它将生成一个“ a.exe”而不是“ a.out”

#include <stdio.h>

main()
{
    printf("hello, world\n");
}
Run Code Online (Sandbox Code Playgroud)
  1. “ a.out”和“ a.exe”有什么区别?
  2. 为什么我得到的是“ a.exe”而不是“ a.out”?

CIs*_*ies 5

这取决于您的平台。例如,如果不提供任何其他参数,gcc它将.out在linux和.exeWindows 上生成。(即运行cc / gcc "source")。

您可以强制gcc产生.out与窗口gcc "source" -o "dest.out"

如果您的编译器默认输出一个扩展名(对于您而言,这似乎.exe是默认值,对于Windows来说完全可以),我会坚持使用它。无需担心不会获得其他类型。