使用 Eclipse 运行.exe C 代码文件
Run .exe file of C code using Eclipse
我用Eclipse IDE用C语言制作了一个非常简单的基本代码。
日食详细信息:
- 面向 C/C++ 开发人员的 Eclipse IDE 版本
- :君诺服务版本2
- 内部版本号:20130225-0426
这是代码:
#include <stdio.h>
int main( int argc, char ** argv ) {
printf("Hello, World!n");
return 0;
}
在Eclipse中成功运行,它会在Project/Debug目录中生成.exe和.o文件。我正在尝试运行该.exe文件,但它不起作用。
Eclipse 的行为就像它运行程序非常快,然后终止它。窗口出现,但运行.exe时没有任何反应。它看起来就像一个对话框的闪光。
应该是什么问题?我不想更改IDE,我已经尝试了以下两件事:
- Eclipse CDT 不会运行已编译的 exe 文件
- Eclipse 无法运行我的 exe 文件
从命令提示符窗口运行程序。如果您只是双击exe文件..它只是运行程序并立即关闭。您将没有时间看到它。
通过导航到目录并执行./yourexefile
,通过cmd
窗口运行它
或者双击执行此操作的一种糟糕方法是这样做:
#include <stdio.h>
int main( int argc, char ** argv ) {
int n;
printf("Hello, World!n");
scanf("%d",&n); // this will force the execution window to stay open until you put in some input
return 0;
}
您还可以执行以下操作:
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char ** argv ) {
printf("Hello, World!n");
system("pause");
return 0;
}
另一种方式(更美观):
#include <stdio.h>
int main( int argc, char ** argv ) {
printf("Hello, World!n");
printf(" Press enter to exitn");
getchar();
return 0;
}
Windows 正在打开程序的命令提示符,运行 print 语句,然后关闭窗口(因为函数已结束)。
如果要查看程序的结果,请运行命令提示符,导航到.exe文件的目录,然后从那里运行它。
你也应该试试这个:
在"项目资源管理器"视图中右键单击项目名称,然后转到"运行方式"并单击"本地 C/C++ 应用程序
相关文章:
- 在C++代码中包含opencv时,使用ctypes创建.so文件
- 此代码编译良好,但文件未创建?请指出错误
- 找不到Linux Visual Studio代码C++文件
- C++(.cpp文件和.h文件)拆分代码并添加一个函数,提取 - 这很容易吗?
- Visual Studio代码文件未输出
- 是否可以使用 GCC 编译具有特定编译器标志的代码文件的一部分?
- 如何从ifstream加载LLVM比特代码文件
- 在同一代码文件中包括 Directx 9 和 10
- 如果我只想要架构良好的工作区,但不一定是分开的编译,如何在C++中组织头/代码文件
- 使用 Eclipse 运行.exe C 代码文件
- 是否可以稍后在代码(C++ I/O 文件)中使用输出文件作为输入文件
- 匿名命名空间-在头文件和代码文件中都有意义
- 代码文件外的代码文档
- 在静态库中硬编码的代码文件和头路径
- 更快地解析代码文件
- 为什么有些代码文件使用 close() 而不包含 unistd.h
- 在代码(.c文件)我如何找到linux发行版名称版本
- 在一个代码文件中使用头文件,反之亦然
- SonarQube未分析带有警告的C++代码文件不在项目目录下
- Qt 创建器代码文件重构