Problem Solved!
Problem Solved!
Last edited by Mrzach3590; 07-25-2006 at 10:56 PM.
What does "won't run correctly in the compiler" mean? Compiler crashes? Gives errors? Program runs but exits right away?
It runs and it lets me enter the 2 #'s but when i hit enter compiler exits out and wont add
It runs and it lets me enter the 2 #'s but when i hit enter compiler exits out and wont add
Add 2 std::cin.get() to the end of your code. You didn't tell it to wait for you to see the result.
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
This is a common problem. Check the FAQ about waiting for a keypress. One simple solution is to add std::cin.ignore() after the call to std::cin >>, and then add std::cin.get() before the return 0. The ignore ignores the newline from when you hit <enter> after inputting the two numbers, the get() waits for you to hit <enter> again so it can get another character.
Hah ok it works thanks a ton I danced in my chair rofl. Now i can move past page 6!
arrgggh, stop asking this question! seriously it's been asked and answered so many times on this forum that I propose an instant ban on anyone posting it.
READ THE <insert diety here>-DAMNED FAQ
"I saw a sign that said 'Drink Canada Dry', so I started"
-- Brendan Behan
Free Compiler: Visual C++ 2005 Express
If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?
ok, anyone know how to write a program in for and while to print the numbers from 10 down to 0?
Could you help me write one lol, the book i got has it for a practice question but really didnt go over it, or atleast i dont think it did.
Ok, first off, for and while are loops. They can execute a sequence of code a set amount of times, hence the name loop.
The format of the for loop is as follows -
the something is normally an integer for regular purposes, but it can be anything. the while can be like thisCode:for ( something = initial condition; something less (etc) than final condition; change the value of something ) { // Do something here. }
If you set the conditions of those loops accordingly, and have a std::cout<< to output the value of the number being changed by the loop, you should get the program to work.Code:while ( something is less/greater/not equal etc to something else ) { // Do something here }
>>ok, anyone know how to write a program in for and while to print the numbers from 10 down to 0?
Isn't it a book exercise?
You passed page 6 when you posted 6 posts. You want to keep the number of your post equal to page number of the book you are reading?
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
Thanks twomers! I successfully wrote a while loop!
New question up top, im a hardcore noob to programming rofl.