C++ file not working?

Posts 1–11 of 11 · Page 1 of 1
C++ file not working?
Hey I just made a little c++ file and when i debug and build and stuff it works perfectly fine. But then i tried using the exe from the project's folder and it just shows the console but closes when i try to type in my cin part of the code. does anyone kno why?
try putting in cin.get(); more than once right after each other because sometimes that's what happens.
LOL I just started learning so i just made a celsius to fahrenheit converting program.
#include <iostream>

int main()
{
using namespace std;
int Celsius;
int Celsiuss;

cout << "Please enter a Celsius value: ";
cin >> Celsius;
Celsiuss = 1.8 * Celsius + 32;
cout << Celsius << " degrees Celsius is " << Celsiuss << " degrees Fahrenheit." << endl;
return 0;
}

like it works if i debug from microsoft visual but from like project's folder the exe doesn't work. it just shows the console and first line. When i type in the number and press enter it just closes.
Code:
#include <iostream>
using namespace std;

int main()
{
int Celsius;
int Celsiuss;

cout << "Please enter a Celsius value: ";
cin >> Celsius;
Celsiuss = 1.8 * Celsius + 32;
cout << Celsius << " degrees Celsius is " << Celsiuss << " degrees Fahrenheit." << endl;
system("pause");
return 0;
}
WHOA BRO!!! THNX

lol mind telling me what that system("pause") thing does?

btw it only worked on the release exe not the debug exe but eh it still works.
system("pause")

pauses the console
NO NO NO NO NO dont use system ("pause").... its one of the most frowned upon things in coding

trust me its not good... compilers do not like it lol :\
Quote Originally Posted by FailHacker View Post
NO NO NO NO NO dont use system ("pause").... its one of the most frowned upon things in coding

trust me its not good... compilers do not like it lol :\
Well i never had any problems with it ....
No, don't make it a habit to use the system() functions unless you REALLY need it.


Instead of system("PAUSE"); use: cin.get();. It looks more proffesional too when you use it.
Quote Originally Posted by FailHacker View Post
NO NO NO NO NO dont use system ("pause").... its one of the most frowned upon things in coding

trust me its not good... compilers do not like it lol :\
Why not? If you can't provide a reason then there's no truth behind it.

Quote Originally Posted by 258456 View Post
No, don't make it a habit to use the system() functions unless you REALLY need it.


Instead of system("PAUSE"); use: cin.get();. It looks more proffesional too when you use it.
Professional? No it doesn't.
Posts 1–11 of 11 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Need help?