multiple word error



 DEVELOP > c-Plus-Plus > multiple word error

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Giovanni Noppe"
Date: 19 Nov 2003 10:36:31 AM
Object: multiple word error
Hello,
I'm writing a program, but I've got a question. I wrote a simple program
that explains my problem. First you must give in an integer and next you
must give a string containing multiple words. If I put an integer in my
variable that is okay, but I have to hit enter twice instead of once for my
string. Is there someone who knows how I can solve this problem ?
Thanks,
Giovanni Noppe,
noppe.g@wanadoo.be
////////////////////////////////////////////////////
#include <string>
#include <iostream>
using namespace std;
void main()
{
int getal;
string zin;
cout<<"Integer : ";
cin>>getal;
cin.ignore(255,'\n');
cin.clear();
cout<<"String : ";
getline(cin,zin);
cout<<"\n\n\n";
cout<<getal<<endl;
cout<<zin;
}
////////////////////////////////////////////////////
.

User: "Victor Bazarov"

Title: Re: multiple word error 19 Nov 2003 10:43:17 AM
"Giovanni Noppe" <noppe.g@wanadoo.be> wrote...

I'm writing a program, but I've got a question. I wrote a simple program
that explains my problem. First you must give in an integer and next you
must give a string containing multiple words. If I put an integer in my
variable that is okay, but I have to hit enter twice instead of once for

my

string. Is there someone who knows how I can solve this problem ?

Get a better version of the standard library. See www.stlport.org


Thanks,

Giovanni Noppe,
noppe.g@wanadoo.be

////////////////////////////////////////////////////
#include <string>
#include <iostream>
using namespace std;

void main()
{
int getal;
string zin;
cout<<"Integer : ";
cin>>getal;
cin.ignore(255,'\n');
cin.clear();
cout<<"String : ";
getline(cin,zin);
cout<<"\n\n\n";
cout<<getal<<endl;
cout<<zin;
}
////////////////////////////////////////////////////


.

User: "Karl Heinz Buchegger"

Title: Re: multiple word error 19 Nov 2003 10:55:11 AM
Giovanni Noppe wrote:


Hello,

I'm writing a program, but I've got a question. I wrote a simple program
that explains my problem. First you must give in an integer and next you
must give a string containing multiple words. If I put an integer in my
variable that is okay, but I have to hit enter twice instead of once for my
string. Is there someone who knows how I can solve this problem ?

Any chance you are using VC++ 6.0?
This (or a very similar) behaviour is a documented bug with that compiler.
For fixes see: http://www.dinkumware.com/vc_fixes.html
--
Karl Heinz Buchegger
kbuchegg@gascad.at
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER