Program keeps exiting after I enter the value for number of dollars. I am new, and am sure the answer is obvious, but I cannot seem to figure it out. I also am receiving an error stating that visual studio cannot find object files for debugging, and that subsequent failures will be logged to the debug pane.
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.
When you enter for "dollar" exactly what do you type? Do not leave anything out.
As I looked over your program I noticed that lines 13 - 17 are missing semi-colons and also line 39.
I was thinking you might have entered "$10" where the "$" would cause cin to fail which would not allow any other entries. Just a thought for now. I load up your program and give it a test.
Be patient, it could be tomorrow morning before I can get back to you.
Handy Andy you are amazing. The problem was the semi colons, I figured it was something in plain sight. You are very much appreciated, as I have been messing with this for about 3 hours now thinking something was wrong with my computer. I am sure I will run into you again on here. Thank you much!
After fixing the semi-colon problem the program worked fine. I could not break it unless I entered something other than a number.
At some point you might want to consider this or your program:
1 2 3 4 5 6 7 8 9 10 11 12
//input dollars made
std::cout << "how many dollars did you receive: ";
std::cin >> dollar;
while (!std::cin)
{
std::cout << "\n Error message of your choice" << std::endl;
std::cin.clear(); // <--- Clears the state bits that caused cin to fail.
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // <--- Add header files "chrono" and "thread".
std::cin >> dollar;
}