🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: att.lang.c++
Article #153

cin.getline problem

#153
From: tony
Date: Sun, 31 Jan 1999 00:00
16 lines
959 bytes
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);
}

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
Technical Details
Message-ID: <bo4t2.18070$%3.1222@wards>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d4ba,d6adead9ee0f9d93,start
X-Google-Attributes: gid10d4ba,public
From: "tony" <tony@netuk.force9.co.uk>
Subject: cin.getline problem
Date: 1999/01/31
Message-ID: <bo4t2.18070$%3.1222@wards>
X-Deja-AN: 439142593
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
X-Complaints-To: abuse@plus.net.uk
X-Trace: wards 917820039 195.166.147.132 (Sun, 31 Jan 1999 22:00:39 BST)
NNTP-Posting-Date: Sun, 31 Jan 1999 22:00:39 BST
Newsgroups: att.lang.c++