seux
13th August 2011, 18:59
Hello everyone,
I had the following piece of code:
int iCounter = 0;
std::string str;
std::stringstream sstr;
sstr << "Number :" << "\t" << iCounter++ << "\t" << iCounter++ << "\t" << iCounter++;
str.append(sstr.str());
When i now output the string it looked like this:
Number : 2 1 0
instead of Number : 0 1 2
and I even got a warning that iCounter may be undefined...I do not know whats wrong there, I also tried it out with standard c++ in a console application and it worked.
So, I decided to switch to QTextStream instead of stringestream, which looks like this:
int iCounter = 0;
std::string str;
QTextStream sstr;
sstr << "Number :" << "\t" << iCounter++ << "\t" << iCounter++ << "\t" << iCounter++;
str.append(sstr.string()->toStdString());
But at the line of 5 the application crashes...Why is both not working?
I had the following piece of code:
int iCounter = 0;
std::string str;
std::stringstream sstr;
sstr << "Number :" << "\t" << iCounter++ << "\t" << iCounter++ << "\t" << iCounter++;
str.append(sstr.str());
When i now output the string it looked like this:
Number : 2 1 0
instead of Number : 0 1 2
and I even got a warning that iCounter may be undefined...I do not know whats wrong there, I also tried it out with standard c++ in a console application and it worked.
So, I decided to switch to QTextStream instead of stringestream, which looks like this:
int iCounter = 0;
std::string str;
QTextStream sstr;
sstr << "Number :" << "\t" << iCounter++ << "\t" << iCounter++ << "\t" << iCounter++;
str.append(sstr.string()->toStdString());
But at the line of 5 the application crashes...Why is both not working?