I cant use console application
-
thanks dears .
i have not any code. just i tested it and didnt get any result .
my simple code is :
@
#include <QCoreApplication>
#include <iostream>using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
cout<<"aaaa";
//printf("ssss");
return a.exec();
}
@and i am in ubuntu 12.04 OS with qtcreator 2.5 and qt4.8.1 sdk.
when i execute that code a empty terminal box opens and i can write into but it doesnt any work!
-
-
I'm not quite sure about how this is on Linux, but on the Windows platform applications can be compiled as "Windows" or as "Console" applications. That's a Linker option. If you compile as "Windows", which is the default for GUI apps, then the app doesn't have a console. And even if you run it from a console - or allocate a console at runtime via AllocConsole() function - output to the console via "stdout" or "cout" doesn't work. Bummer! That's because the C Runtime never binds the stdout/stderr or cout/cerr to the console - because it doesn't expect a console to be there. There are some workarounds for that. Maybe on Linux there is a similar issue. I'm not quite sure. Maybe somebody more familiar with Linux can give an answer about that...
-
-
[quote author="batista" date="1361676392"]@
//This is working!!!, put endl for end cout#include <QCoreApplication> #include <iostream> using namespace std; int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); cout<<"aaaa" << endl; //printf("ssss"); return a.exec(); }@[/quote]
i put it but didnt work !
-
@
//My test in debian and ubuntu 12.10 work fine.batista@dellxps:~/NetBeansProjects/QtTes$ cat test.cpp
#include <QCoreApplication>
#include <iostream>using namespace std; int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); cout<<"aaaa" << endl; //printf("ssss"); return a.exec(); }batista@dellxps:~/NetBeansProjects/QtTes$ ./QtTes
aaaa@