YEAH
But, you'd find out faster if you'd just pressed the compile button.
Anyways, so yeah. Hai guys, if you know me, then I love you. If you don't well, we can get to know each other. However, , I was reading up on C, yes C, not C++, because I wanna learn C before C++....again.
Okay, so I'm just starting again, I only did about the intro, yeah it's things I know. But a question came to mind.
You know how getchar() or cin.get() is used to wait for a char input from the user before it closes? I was wondering if it was possible to use getchar() or cin.get() in an if statement.
As in, it would ask the user for input, and then if the user inputs a specific character, the program then instead of closing, would skip to the if statement? ._.;
Something like this is what I'm trying to get at.
[php]
int main()
{
int x =10;
cout<< x;
cin.get();
if(cin.get() == 2){
// Do whatever I want here.
}
return 0;
}
[/php]
Is this possible? Or what's the other way to do it? I can think of a couple but yeah, this is a question I had.
Thanks gais. Love yew. ♥
YEAH
But, you'd find out faster if you'd just pressed the compile button.
There are two types of tragedies in life. One is not getting what you want, the other is getting it.
If you wake up at a different time in a different place, could you wake up as a different person?
Hell_Demon (02-13-2010)
Did you include namespace std?
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
You do realise that == 2 is not the same as "2" right?
Ah we-a blaze the fyah, make it bun dem!
crushed (02-13-2010)
Well its about time.... >_>
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower