【问题标题】:Codelite C++ program not compiling and runningCodelite C++程序未编译和运行
【发布时间】:2015-04-07 16:57:26
【问题描述】:

我昨天安装了 codellite 7.0,并一直在尝试使用它。但是好像有点问题。我无法运行任何代码。 现在代码很简单。

#include <stdio.h>

int main(int argc, char **argv)
{
   printf("hello world\n");
return 0;
}

但是,它返回以下内容并且输出为空白,Press any key to continue

当前工作目录:D:\ .....

运行程序:le_exec.exe ./1

程序退出并返回代码:0

【问题讨论】:

    标签: c++ codelite


    【解决方案1】:

    你的程序运行良好,唯一的问题是在printf之后程序返回0并立即关闭,它确实运行并打印出“hello world”,你只是没有时间看它.

    要让程序等待用户输入以便您可以看到输出,请使用cin.get()

    #include <stdio.h>
    #include <iostream>
    
    int main(int argc, char **argv)
    {
       printf("hello world\n");
       std::cin.get();
    return 0;
    }
    

    【讨论】:

    • Codelite 在Project settings/General/Pause when execution ends也有一个选项
    • 你能给我这个Pause when execution ends的确切位置吗?我没有找到Project settings/General
    • 我也尝试添加std::cin.get(),但结果还是一样。带有Press any key to continue 的空白终端
    • 在项目的设置中,在Common settings/general中。
    猜你喜欢
    • 2022-09-27
    • 1970-01-01
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    相关资源
    最近更新 更多