- Joined
- Nov 5, 2006
- Messages
- 5
- Reaction score
- 0
Hey all i've almost completed a fairly large project but am having some strange problems within one of my functions using getline(). After entering the first string the program skips over the rest of the input and prompts for supplier again.
Here's the function:
#include <iostream>
#include <string>
using namespace std;
...
...
...
int ConstantVariables(ShippingDetails &details)
{
while(1)
{
/* prompt user for input */
cout << " Supplier: ";
getline(cin, details.supplier);
cout << endl << " Date: ";
getline(cin, details.date);
char option;
cout << endl << " Are the values you entered correct?" << endl << endl;
cout << " <y/n> ";
cin >> option;
if(option == 'y' || option == 'Y')
break;
}
return 1;
}
The struct details contains strings supplier and date, along with some other which i have omitted as they do not cause the problem.
any help would eb appreciated.
Here's the function:
#include <iostream>
#include <string>
using namespace std;
...
...
...
int ConstantVariables(ShippingDetails &details)
{
while(1)
{
/* prompt user for input */
cout << " Supplier: ";
getline(cin, details.supplier);
cout << endl << " Date: ";
getline(cin, details.date);
char option;
cout << endl << " Are the values you entered correct?" << endl << endl;
cout << " <y/n> ";
cin >> option;
if(option == 'y' || option == 'Y')
break;
}
return 1;
}
The struct details contains strings supplier and date, along with some other which i have omitted as they do not cause the problem.
any help would eb appreciated.