qt creator如何写最基础的C++控制台程序?

gaelookair 2010-12-23 10:33:20
本人大一学生,对新事物感兴趣故下载了qt creator for win
目前编程应用仅限于做ACM题目
学着visual studio的样子建立了空工程然后写了

#include<iostream>
#include<string>
using namespace std;
int main()
{
cout<<"hello world"<<endl;
}
然后build run;
没有出现程序窗口,而只是回复了Starting C:\Users\renkai\Documents\project\hello-build-desktop\debug\hello.exe...
C:\Users\renkai\Documents\project\hello-build-desktop\debug\hello.exe exited with code 0
建立qt控制台程序的话,又会出现

#include <QtCore/QCoreApplication>

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

return a.exec();
}
这些导致提交不能AC的赘余代码,请问我要怎么做?
...全文
1059 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
fzhmoive 2011-08-07
  • 打赏
  • 举报
回复
顶一楼
BizSpark 2011-01-06
  • 打赏
  • 举报
回复
我按楼主的做了。还是不行。我创建的qt程序是 Qt Gui Application.
如果我的程序是 Qt Console Application 用标准 std::cout 就能够输出.
gaelookair 2010-12-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 mylanyuer 的回复:]

C/C++ code

#include<iostream>
int main()
{
std::cout << "hello world!" << std::endl;
system("pause");
return 0;
}



默认是在“Application Output”中输出的,要想在控制台输出显示,点击左侧的“Projects”,上面的“Run Se……
[/Quote]
system("pause"); 要加头文件#include <stdlib.h>才能用啊
加了之后,按run打开了两个窗口cmd和qt_creator_process_stub;
但是都没输出helloworld,按start debugging打开qt_creator_process_stub,也没任何输出
月中蓝 2010-12-23
  • 打赏
  • 举报
回复

#include<iostream>
int main()
{
std::cout << "hello world!" << std::endl;
system("pause");
return 0;
}


默认是在“Application Output”中输出的,要想在控制台输出显示,点击左侧的“Projects”,上面的“Run Settings”,在下面有个选项“Run in terminal”,选中就可以了
luawkk 2010-12-23
  • 打赏
  • 举报
回复
我也想搞qt开发的,可是安装后 什么也不懂,就卸载了 哈

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧