Mail Archives: djgpp/1999/03/30/06:11:32
Message-ID: | <3700A7F5.84BDE27F@xoommail.com>
|
From: | Ishpeck <ishpeck AT xoommail DOT com>
|
Organization: | Lunaticnologies
|
X-Mailer: | Mozilla 4.01 [en] (Win95; I)
|
MIME-Version: | 1.0
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Using cin and getline
|
X-Priority: | 3 (Normal)
|
References: | <3700A43A DOT 776D793F AT home DOT com>
|
X-Corel-MessageType: | EMail
|
Lines: | 32
|
NNTP-Posting-Host: | 192.41.73.9
|
X-Trace: | news6.ispnews.com 922789808 192.41.73.9 (Tue, 30 Mar 1999 05:30:08 EST)
|
NNTP-Posting-Date: | Tue, 30 Mar 1999 05:30:08 EST
|
Date: | Tue, 30 Mar 1999 03:31:17 -0700
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
I'm not sure, but, have you cleared the standard input buffer? That
usually works for me whenever I try to get data and it doesn't work.
Shaun Jackman wrote:
>
> I'm having a problem with the following code snippet, where the input
> from cin is (for example):
> [BEGIN input]
> abcdefgh
> ijklmnop
> [END input]
>
> string name;
> char buf[80];
> cin >> name;
> cin.getline(buf,80);
>
> Name is written to properly, but it doesn't even wait for input when it
> comes to the getline. The following code snippet works.
>
> string name;
> char buf[80];
> cin >> name;
> cin.get(); // This never happens
> cin.getline(buf,80);
>
> The above is a real hack. What is my problem, and how do I fix it?
>
> Thanks for your help,
> Please reply by e-mail as well if possible,
> Shaun Jackman
> sjackman AT home DOT com
- Raw text -