cin.ignore question

Joined
Oct 4, 2008
Messages
1
Reaction score
0
I am slightly confused as to how cin.ignore works. I'll try to make this short. I need to write a program where the user inputs a bunch of data in 1 string, for example : 46728s1000 2750.55John Brown

I need to extract the different parts of that input. I need to extract the first 5 digits, the 's', the 1000, the 2750.55 and John Brown.

Code:
int getInformation (bool isFirstInput)

{	int accountNumber;
	char accountType;
	int minBalance;
	double oldBalance;
	string firstNamelastName;
	const string welcomeMessage = "Welcome to Brandon Lashmet's payroll program\n. Please enter account number, account type, minimum balance, a space, old balance, and first and last name of account owner.";

	if (isFirstInput==true)
	{
		cout<<welcomeMessage;
	}
	else
	{
		cout<< "Thank you. Please enter next user's information";
	}
		
		cin>> accountNumber;
		cin.ignore(5);
		cin>> accountType;
		cin.ignore(6) ;
		cin>> minBalance; 
		cin.ignore(11);
		cin>> oldBalance;
		getline(cin, firstNamelastName);

}
Any help would be much appreciated 8)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top