Thread: Finding the ASCII value of a string?

  1. #31
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Also, while we're here: "1/12" is just the same as "0" -- and if you had tried the (correct) 1.0/12.0, you would have gotten an error message, since you can't use ^ with a floating point number.

  2. #32
    Registered User
    Join Date
    Dec 2007
    Posts
    28
    Oh, why is that?
    Yeah, the aforementioned edit didn't work... It gives me a syntax error...

  3. #33
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Nicheter View Post
    Yeah, the aforementioned edit didn't work... It gives me a syntax error?
    So, what have you currently got? You should have tabstops change as well as the pow() function call.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #34
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If it were me, I would pre-calculate (2^(1/12)) and do something like
    Code:
    pow(1.05946309436,i)
    to avoid this 1/12 problem.

    (Especially since 2^(1/12) doesn't change from run to run.)

  5. #35
    Registered User
    Join Date
    Dec 2007
    Posts
    28
    yeah, that does fix everything, would have done it myself, lacking a good calculator, i figured the program could do it.
    To be clearer, that revealed the error, namely a stray parenthesis.
    EDIT: Since note is a pointer, would I use
    Code:
    scanf("%5s",note);
    or
    Code:
     scanf("%5s",&note);
    EDIT(again): Yeah, sorry about the stupid question, I figured it out already...
    Last edited by Nicheter; 07-24-2008 at 10:00 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 03:27 AM
  3. string to ASCII and back...
    By skora in forum C Programming
    Replies: 3
    Last Post: 11-23-2003, 10:59 PM
  4. Again Character Count, Word Count and String Search
    By client in forum C Programming
    Replies: 2
    Last Post: 05-09-2002, 11:40 AM
  5. converting a string to it equivalent ascii value
    By pauljhot in forum C Programming
    Replies: 12
    Last Post: 02-16-2002, 02:35 AM