C++ School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C++ Expert!

Join 300,331 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,804 people online right now. Registration is fast and FREE... Join Now!




Using peek to eleminate $

 

Using peek to eleminate $

codecsmash49

18 Jan, 2009 - 11:29 AM
Post #1

New D.I.C Head
*

Joined: 9 Dec, 2008
Posts: 26

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

CODE

       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

User is offlineProfile CardPM
+Quote Post


KYA

RE: Using Peek To Eleminate $

18 Jan, 2009 - 01:32 PM
Post #2

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 11,186



Thanked: 489 times
Dream Kudos: 2825
Expert In: C, C++, Java

My Contributions
Is the user inputting a $? user.input should be an integer/double rather then a string, no?
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic

Time is now: 11/7/09 04:22PM

Live C++ Help!

Be Social

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

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month