Last active
December 30, 2015 05:39
-
-
Save skairunner/7784383 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; // USING NAMESPACE SEXUALLY TRANSMITTED DISEASE | |
int doubleNumber(int x) // HOLY SHIT I WROTE A FUNCTION I AM AWESOME | |
{ | |
return x * 2; // DOUBLE THAT GOD DAMN NUMBER | |
} | |
int main() | |
{ | |
int input = 0; // INITIALIZE THAT FUCKING VARIABLE | |
cin >> input; // AWW YEAH SOME USER INPUT | |
if (cin.fail()){// THIS IS SUPPOSED TO STOP THE FUN BEFORE IT HAPPENS | |
// If cin.fail() is true, that means we couldn't extract wahtever is in cin to input, which in this case is a number. | |
cout << "Sorry bro/sis!"; // YEAH IM FUCKING SORRY | |
cin.clear(); // reset the state bits back to goodbit so we can use ignore() | |
cin.ignore(1000, '\n'); // clear out the bad input from the stream | |
cin.ignore(2); // THIS IS PROABLY WHERE THE ERROR IS, IT CRASHES ANYWAYS | |
return 0; | |
} | |
cout << "\n" << doubleNumber(input) << endl; // PRINT THE GOD DARNED THING | |
cin.ignore(3); // I DONT KNOW WHAT ACTUALLY HAPPENS HERE BUT SKY TOLD ME IT WORKS | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment