Hey everyone,
I need to print the contents of a 2D array to the screen (command line) for a project I'm working on. Can someone point me in the right direction?
Hey everyone,
I need to print the contents of a 2D array to the screen (command line) for a project I'm working on. Can someone point me in the right direction?
can you print a single element of that array? if so then read about "for loop"
Hi
looking at ur problem statement, it sounds very simple. however if you are not able to see anything on the console which u have print then do rememeber to modify your pro file with
There a function in Qt called qDebug() go through that might be useful in your case.
Thanks guys,
I'm actually very familiar with C++ in general, but am very new to Qt. I'm not sure which functions to call to print to a command line for Qt. Whereas in C++ I would do something like:
Qt Code:
ary[10][10]; for (int i = 0 ; i < 9 ; i++) for (int k = 0 ; k < 9 ; k++) cout << ary[i][k] << endl ;To copy to clipboard, switch view to plain text mode
I have no idea how to produce output using Qt.
Did u try running the code ? As said by vishwajeet you need to add CONFIG += console in your .pro file.
Also instead of cout, you may have a look at qDebug
Hi ctote,
You can try the following code as example:
Qt Code:
#include <QCoreApplication> #include <QDebug> #include <iostream> #include <cstdlib> using namespace std; int main(int argc, char *argv[]) { ary[10][10]; for (int i = 0 ; i < 9 ; i++) for (int k = 0 ; k < 9 ; k++) cout << ary[i][k] << endl; // or use qDebug() << ary[i][k]; }To copy to clipboard, switch view to plain text mode
not forgot of use CONFIG+=console and QT -= gui
Bookmarks