View Full Version : cout output wrong order and incomplete.
rnodal
May 4th, 2008, 08:34 PM
Hello all:
My little c++ program is having a weird issue.
cout << "Searching SID's for " << airport_name << " ..." << "\n";
That line is supposed to output something that looks like this:
Searching SID's for MADEIRA ...
Instead I get:
...ching SID's for MADEIRA
As you can see it is replacing the first letters of the word Searching with the "...". Any clues why that is the case? Thanks a lot for your time.
-r
LaRoza
May 4th, 2008, 08:43 PM
Hello all:
My little c++ program is having a weird issue.
cout << "Searching SID's for " << airport_name << " ..." << "\n";
I am guessing:
cout << "Searching SID's for " << airport_name << " ..." << endl;
Maybe that will work?
rnodal
May 4th, 2008, 08:51 PM
Thanks for your replay :). I have tried that and also putting flush(cout) before that line but nothing seems to work. The line works like this:
cout << "Searching SID's for " << airport_name << "\n" << endl;
But that is not the output that I want.:confused: I don't know what could be causing the problem.
-r
tseliot
May 4th, 2008, 08:58 PM
This code works well here:
#include <iostream>
#include <string>
int main(int argc, char** argv)
{
using namespace std;
string airport_name = "MADEIRA";
cout << "Searching SID's for " << airport_name << " ..." << "\n";
return 0;
}
A screenshot (http://albertomilone.com/madeira.png).
stroyan
May 4th, 2008, 09:09 PM
I expect that airport_name contains a carriage return character.
that makes the terminal move the cursor to the start of the line.
Then the "..." overwrites the front.
You should filter your airport_name value to remove control characters.
rnodal
May 4th, 2008, 10:33 PM
That was it! I forgot to clean the string since it came from a file. Thanks a lot all for your help.
-r
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.