What is the correct way to enter a float pointer?

This is a discussion on What is the correct way to enter a float pointer? within the C++ Programming forums, part of the General Programming Boards category; What am I messing up here? I am simply trying to enter a number as a dynamic float. I get ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    32

    What is the correct way to enter a float pointer?

    What am I messing up here? I am simply trying to enter a number as a dynamic float. I get the error:

    error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'float *' (or there is no acceptable conversion)

    Code:
    cout << "Enter a number: ";
    float* entry;
    entry = new float;
    cin >> entry;                                // Compliler does not like the cin	
    cin.ignore(100, '\n');
    cout << endl << endl << "Value entered: " << entry << endl << endl;

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    cin>>(*entry)

    Why are you using a pointer? Why not just use a normal float?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    32
    Grrrrrrr, I forgot about de-referencing.

    As for why...because I couldn't remember how

    Thanks for the help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Float Function Issues
    By GCNDoug in forum C++ Programming
    Replies: 5
    Last Post: 10-29-2007, 03:25 PM
  2. Moving Average Question
    By GCNDoug in forum C Programming
    Replies: 4
    Last Post: 04-23-2007, 11:05 PM
  3. Repetition in do{}while
    By Beast() in forum C Programming
    Replies: 25
    Last Post: 06-16-2004, 10:47 PM
  4. Enistine program
    By Mac_the vamp in forum C Programming
    Replies: 2
    Last Post: 11-11-2002, 09:56 AM
  5. terminate 0 - PLEASE HELP
    By Unregistered in forum C Programming
    Replies: 11
    Last Post: 11-21-2001, 06:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21