Thread: what's wrong here?

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    18

    what's wrong here?

    Please, i cant find the mistake here:


    char dec = "10.45";

    float numb;

    numb = (float)dec;

    numb = numb/2;


    i have the following message:

    illegal operands 'double'/'int'

    i have also tried

    numb = numb/2.0

    and its given:

    illegal operands 'double'/'double'

    so, if its wrong, how do i make mathematical operations between double-int, double-float, double-double???

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    char dec = "10.45";
    That's your first mistake. 'dec' is a single character. Not a pointer.

    numb = (float)dec;
    That's your second. You cannot cast a string as a floating point number.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 03:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 10:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 12:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 01:04 PM