Simple Question relating to the IOStream Lib and Cin
When I'm testing a piece of code (by your tutorials) I get a problem, it pertains to "cin>>" cin is an input stream, I've included the library in the header, and also included the "using" arguement (because I'm not using everything in the header file of the iostram.) However cin isn't giving me the input area, thus recieving the number isn't working either.
Heres the code:
Code:
#include <iostream>
using std::cout;
using std::cin;
#include <conio.h>
int main()
{
int input;
cout<<"1. Play game\n";
cout<<"2. Load game\n";
cout<<"3. Play multiplayer\n";
cout<<"4. Exit\n";
cin>>input;
switch (input)
{
case 1:
cout<<"Playing game...";
break;
case 2:
cout<<"Loading game...";
break;
case 3: //Note use of : not ;
cout<<"Going into Multiplayer mode...";
break;
case 4:
return 0;
default:
cout<<"Error, bad input, quitting";
}
return 0;
}
Re: Simple Question relating to the IOStream Lib and Cin
before each break in the cases, add a
Re: Re: Simple Question relating to the IOStream Lib and Cin
Quote:
Originally posted by Eric Hansen
before each break in the cases, add a
Thats not the problem, heres an example
http://phpnetzero.sourceforge.net/1.gif