HelpRecently started having some issues.

Posts 1–4 of 4 · Page 1 of 1
Recently started having some issues.
todays my third day of learning C++

the problem im having is that




#include <iostream> //checking new system
using namespace std;
int main()
{
int age = 21;//true value
char gender = 'm';





age++;
cout << "Enter your age:";
cin >> age;
cout << "You are : " << age << "years old and a fat gay cunt" << endl;
Console.Read();

}


this works perfectly when i use CTRL+f5 to run it however when i try to run the exe from the debug folder; the cmd prompt instantly closes after the output gets displayed

It's so fast that i cant even read the output.


I am using viusal studio 2017 with a windows 10 as the OS

also how would i export the exe if i need to send it to someone as a practical joke.
fixed it



#include <iostream>
#include <cstdio>//checking new system
using namespace std;
int main()
{
int age = 16;//true value
char gender = 'm';





age++;
cout << "Enter your age:";
cin >> age;
cout << "You are : " << age << "years old and a fat gay cunt" << endl;
system("pause");

}
It is because the Computer thinks it's done so it closes right away after the output is displayed.
Be aware that if you are sending a binary with this code to a non-Windows platform, even if you cross-compile it, it won't run.
System("pause") is not considered a good way to stop the consol, since it's platform specific. Use cin.get() instead to eliminate this problem.
Not sure this is relevant to your test situation now, but still might be usefull to know.
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us