Inconsistent output to console, need to launch program multiple times before any output is shown (Help)

  • Thread starter Thread starter Crups
  • Start date Start date
C

Crups

Guest
I recently enrolled in a simple c++ course to try and learn the language. However, I've stumbled upon an issue where sometimes running my program (in non-debugging mode) results in no console output whatsoever. And I end up having to try multiple times before text appears in the console. It works just fine in regular debugging mode but the console closes itself so I'd like to avoid using it. The console launches just fine with no errors but there's no text showing.

And before you ask, my subsystem settings in the configuration tab are indeed set to (/SUBSYSTEM<g class="gr_ gr_744 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style replaceWithoutSep" data-gr-id="744" id="744">:CONSOLE</g>).

This appears to be a visual studio problem and I'm wondering if it has anything to do with the current version? As far as I know, this is the latest version of Visual Studio. It's getting really annoying, any ideas on how I can fix it?

In case this actually has something to do with my own code I've included it here:


#include <iostream>
#include <string>
using namespace std;

void PrintIntro();
string GetGuess();

//The entry point for our application
int main() {
PrintIntro();
GetGuess();

}

void PrintIntro() {
//Introduce the game
constexpr int WORLD_LENGTH = 5;
cout << "Welcome to Bulls and Cows, a fun word game.\n";
cout << "Can you guess the " << WORLD_LENGTH << " letter isogram I'm thinking of?\n" << endl;
cout << "Enter here: ";
return;
}

string GetGuess() {
//Get a guess from the player
string Guess = "";
getline(cin, Guess);

//Repeat the guess back to them
cout << "Your guess was: " << Guess << endl;

return Guess;

}

Continue reading...
 
Back
Top