{SOLVED}
I restarted Visual Studio and it work lol
So I was following along with the course and wrote my code. When I compiled and ran it, it just closes on me. I tried searching online for an answer and I found that by adding " cin.get(); " above " return 0; "it works. However, the text part that should say press any key to continue, is missing, and when I press enter the window closes.
I’m just wondering if there is a way to fix my code so I don’t have to include the extra part, or if not having the “press any key to continue” is going to be an issue.
(Sorry if it looks a bit messy)
My code (without cin.get(); ) :
#include<iostream>
using namespace std;
int main()
{
cout<< “Welcome to Bulls and Cows\n” ;
return 0;
}
My code with the extra part:
#include<iostream>
using namespace std;
int main()
{
cout<< “Welcome to Bulls and Cows\n” ;
cin.get():
return 0;
}