Mail Archives: djgpp/1999/01/14/08:42:04
I looked up cin.get in the turbo c++ help file and indeed this problem is what
will, because cin.get doesn't take the delimiter (ENTER in this case, but you can
specify another as the third parameter of cin.get) off the input stream, so the
next times cin.get is called it will see enter immediately, leaving an empty
string. Maybe you can solve it by flushing the input stream in some way, or taking
the enter off the input stream everytime you call cin.get.
Talrid schreef:
> I am trying to make a small one-player MUD-type text game. I made a string
> called command. I'd use cin.get(command, 100), then I'd break the command into
> two parts:the verb and the object. The problem I am having is that when I use
> a loop there is no oppurtunity for the user to enter a command after the first
> time. I tried using a two-diminsional array of this sort
> main()
> {
> char command[100][100];
> int n;
> .....
> cin.get(command[n], 100);
> .....
> n++;
> }
> but it was completely ineffective.
> Also, I tried printing out the output of command after the loop was completed.
> It printed out this:0x53bbfc, which I'm guessing is a memory adress?
> Please tell me if you need to see more of the code. Thanks for any help.
- Raw text -