Codelite C++ program not compiling and running

梦想与她 提交于 2019-12-13 19:17:44

问题


I installed codellite 7.0 yesterday and have been trying to work with it. But there seem to be some problem. I cannot run any code. For now code is pretty simple.

#include <stdio.h>

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

however, it returns following and output is blank with Press any key to continue

Current working directory: D:\ .....

Running program: le_exec.exe ./1

Program exited with return code: 0


回答1:


Your program is running fine, the only problem is that after the printf the program returns 0 and shuts down immediately, it does run and print out "hello world", you just don't have the time to see it.

To make the program wait for user input so that you can see the output use cin.get() :

#include <stdio.h>
#include <iostream>

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


来源:https://stackoverflow.com/questions/29496999/codelite-c-program-not-compiling-and-running

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!