| 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
.
|
|
|
|

|
Related Articles |
|
|