School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,137 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 3,908 people online right now. Registration is fast and FREE... Join Now!



Using peek to eleminate $

Using peek to eleminate $ Rate Topic: -----

#1 codecsmash49  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 26
  • Joined: 09-December 08


Dream Kudos: 0

Post icon  Posted 18 January 2009 - 11:29 AM

I'm writing a code for a user input but i cannot find a good source on how to use "peek"

	   cout << "Balance : ";
		cin >> file.balance;
			if(file.balance < 0)
			{
				cout << "Please Enter postivie numerical value for balance: ";
				cin >> file.balance;
			}
		if(cin.peek() == '$')
		{
			// get one character
			cin.ignore('$')
		}
		//read the number




How do i get the character get.ch?
and then how do i display the new numbers w/o the $ there
Was This Post Helpful? 0
  • +
  • -


#2 KYA  Icon User is online

  • while(sad){!sad; awesome();}
  • Icon
  • View blog
  • Group: Mentors
  • Posts: 13,183
  • Joined: 14-September 07


Dream Kudos: 3000

Expert In: C, C++, Java

Posted 18 January 2009 - 01:32 PM

Is the user inputting a $? user.input should be an integer/double rather then a string, no?
Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month