multiple word error
From: Giovanni Noppe (noppe.g_at_wanadoo.be)
Date: 11/19/03
- Next message: Jeffrey Baker: "Re: Jumps through a program"
- Previous message: jeffc: "Re: Constructor Syntax Problem"
- Next in thread: Victor Bazarov: "Re: multiple word error"
- Reply: Victor Bazarov: "Re: multiple word error"
- Reply: Karl Heinz Buchegger: "Re: multiple word error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 19 Nov 2003 17:36:31 +0100
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;
}
////////////////////////////////////////////////////
- Next message: Jeffrey Baker: "Re: Jumps through a program"
- Previous message: jeffc: "Re: Constructor Syntax Problem"
- Next in thread: Victor Bazarov: "Re: multiple word error"
- Reply: Victor Bazarov: "Re: multiple word error"
- Reply: Karl Heinz Buchegger: "Re: multiple word error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|