![]() |
How to make the console wait until i type somting?
Ok so heres the code
Code:
#include <iostream> |
Re: How to make the console wait until i type somting?
iWord is an int, not a string. cin tries to read until it gets a number, and since there isn't one that confuses it.
So change int iWord to string iWord and this will fix the problem. |
Re: How to make the console wait until i type somting?
Use an if statement to check the answer.
Code:
if (iNumber==8) |
Re: How to make the console wait until i type somting?
Ok where would i add that in?
like under where it asks what is 4+4? |
Re: How to make the console wait until i type somting?
Well, you don't need to ask that sort of question. Have a guess where to put it in, then run the program, and if it doesn't behave as you want, have another guess. With programs this small there aren't many different places to put it so you're going to hit on a valid location fairly quickly.
|
Re: How to make the console wait until i type somting?
Ok thanks i got it but now i want to make it so if i get it wrong ill go to the start and if i get it right i go to the next line ive made a new code its a text adventure and i need help with the question above.
Code:
#include <iostream> |
Re: How to make the console wait until i type somting?
OK so now you'll need some mechanism for looping. There are three basic types of loop in C: for, while and do. Look them up in your textbook, or google them. for is used for counting, and while and do are both the same in terms of looping while a condition is true, but with while the condition is at the start (while X is true, do this) and with do the condition is at the end (do this while X is true). The main difference between do and while is that a do loop always runs at least once; both for and while loops can run no times.
|
| All times are GMT +5.5. The time now is 11:22. |