Pape Traore
Pape Traore

Reputation: 83

C++ cout and endl not printing correctly on terminal

My cout statements don't print correctly on my terminal for some reason. It creates space. When I have the following code:

void Test::testSorted(){
   vector<int> unsorted = {4, 6, 5, 2, 1, 3};
   vector<int> sorted   =  {1, 2, 3, 4, 5, 6};

   cout << "Testing isSorted function for unsorted Pancake ... : " << endl;
   game.setPancakeStack(unsorted);
   bool condition1 = game.isStackSorted(); 

   cout << "Testing isSorted function for sorted Pancake ... : " ;
   game.setPancakeStack(sorted);
   bool condition2 = game.isStackSorted(); 
}

The terminal exactly outputs this with the exact amount of space:

Testing isSorted function for unsorted Pancake ... : 
                                                     Testing isSorted function for sorted Pancake ... :

NOTE: I have been using ncurses for a project and I feel like that might have messed up my shell. But I don't know where to even look to fix this issue

Upvotes: 1

Views: 421

Answers (1)

Lightness Races in Orbit
Lightness Races in Orbit

Reputation: 385274

This symptom is a textbook case of an ncurses application not quitting properly and leaving the terminal in the wrong "mode". Just open a new terminal to fix it.

If the ncurses application did quit cleanly, it's missing some deinitialisations (endwin()?) at the end of main, which is either for you to fix (if you wrote the application) or for you to report to the developers (otherwise).

Upvotes: 1

Related Questions