Article View: att.lang.c++
Article #155Re: cin.getline problem
From: Fredrik Jangvik
Date: Tue, 02 Feb 1999 00:00
Date: Tue, 02 Feb 1999 00:00
50 lines
1947 bytes
1947 bytes
This is a multi-part message in MIME format.
--------------26C1E3A8C84854535484E2F7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi Tony. Try this after the last line in the iteration.
cin.ignore('\n', 100)
/Fredrik
tony wrote:
>
> Hi
> Can anyone explain why this doesn't work?
>
> for(int i=1; i<3;i++)
> {
> cout << "enter first name ";
> cin.getline(first,10);
> cout << "\nenter second name ";
> cin.getline(second,10);
cin.ignore('\n',100); // Here that is.
> }
>
> assuming vars are set up correctly etc. On the second iteration
> it skips the first cin.getline but displays both couts and waits for
> entry of second name. Do i need to flush the buffer after each getline if so
> how?
> Thanks Tony
--------------26C1E3A8C84854535484E2F7
Content-Type: text/x-vcard; charset=us-ascii;
name="jangvik.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Fredrik Jangvik
Content-Disposition: attachment;
filename="jangvik.vcf"
begin:vcard
n:Jangvik;Fredrik
tel;home:0525-29929
x-mozilla-html:FALSE
adr:;;Aff�rsv�gen 16;457 30 TANUMSHEDE;;;Sverige
version:2.1
email;internet:jangvik@telia.com
title:Student of system analysis
x-mozilla-cpt:;-1
fn:Fredrik Jangvik
end:vcard
--------------26C1E3A8C84854535484E2F7--
Technical Details
Message-ID:
<36B74810.3A6B118F@telia.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<bo4t2.18070$%3.1222@wards>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d4ba,d6adead9ee0f9d93 X-Google-Attributes: gid10d4ba,public From: Fredrik Jangvik <jangvik@telia.com> Subject: Re: cin.getline problem Date: 1999/02/02 Message-ID: <36B74810.3A6B118F@telia.com> X-Deja-AN: 439848542 X-NNTP-Posting-Host: t1o21p44.telia.com References: <bo4t2.18070$%3.1222@wards> X-Accept-Language: sv,en Content-Type: multipart/mixed; boundary="------------26C1E3A8C84854535484E2F7" X-Complaints-To: abuse@internet.telia.com Organization: Telia Internet Services Mime-Version: 1.0 Newsgroups: att.lang.c++