Thread: array multiplication odd output

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    38

    array multiplication odd output

    So I have an array : isbn[20][20]

    and then i input : 978-0-306-4061

    then i try to multiply the first character, 9, by one :

    s = isbn[0][0] * 1;

    and instead of 9 i get.. 56.. i don't get why.

    Any ideas?

    Thanks

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    The ascii value for the representation of the char '9'. (Although according to asciitable.com it's 57 not 56).

    If you want to convert that to the numeric value of 9 then you'd need to subtract char '0' first.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    38
    ah yes, you're right its actually 57. so there's no way of just normally adding or subtracting array values?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Invalid Output of Minimum and Maximum Value in Array
    By georgio777 in forum C Programming
    Replies: 10
    Last Post: 09-19-2009, 03:17 AM
  2. array output
    By aama100 in forum C++ Programming
    Replies: 5
    Last Post: 01-29-2008, 04:32 AM
  3. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM