www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/14/08:42:04

From: Henno Vermeulen <Vermeulen AT regiolicht DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: trouble with cin.get()
Date: Thu, 14 Jan 1999 14:34:00 +0100
Organization: Casema Internet
Lines: 28
Message-ID: <369DF248.12DD5780@regiolicht.nl>
References: <19990113174226 DOT 23168 DOT 00000068 AT ng-ce1 DOT aol DOT com>
NNTP-Posting-Host: host148.regiolicht.nl
Mime-Version: 1.0
X-Trace: news.casema.net 916320839 26827 195.212.41.148 (14 Jan 1999 13:33:59 GMT)
X-Complaints-To: abuse AT casema DOT net
NNTP-Posting-Date: 14 Jan 1999 13:33:59 GMT
X-Mailer: Mozilla 4.5 [nl] (Win98; I)
X-Accept-Language: nl
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019