Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

String Question in C

  • 30-05-2005 6:18pm
    #1
    Closed Accounts Posts: 680 ✭✭✭


    In C, if i have a char array char string1[] = "532432" how do i

    1) convert that string to a double or float

    2) convert that double or float back to a string?

    atof doesn't seem to work for me in the way its described online.


Comments

  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    What does:
    double foo; foo = atof(string1); printf("foo=\"%8.2f\"", foo);
    
    give you?

    In what way is atof() not working compared to man pages?


  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    Forgot to mention sprintf()/snprintf() for reversal.


  • Registered Users, Registered Users 2 Posts: 4,003 ✭✭✭rsynnott


    By the way, in general, it's better to avoid using floats; most (all?) library functions use doubles.


  • Registered Users, Registered Users 2 Posts: 4,276 ✭✭✭damnyanks


    Didn;t know that quite handy.

    I lurve c its quite nice indeed also eclipse stinks its too bloaty.

    Indeed


Advertisement