Thread: Function returns null value instead of zero

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    9

    Function returns null value instead of zero

    Ok, i have a function that reads the presses of a keypad attached to a microcontroler that outputs an int value assigned to a specific keypress for example, if the user presses "1" it reurns an integer value of 2048.

    I was given this function to use, and i cannot alter it.

    what i am attempting to do is create a function that takes the values of the function described above and makes the return values useable for doing math (ie, you press one, it returns one).

    where i am running into a problem here is when the user presses zero on the keypad, i have it do return(0)...which returns a null value, as far as i can tell (whatever it returns, it is most certainly not an integer value of 0).

    are there any tricks that i should know about to return an integer value of 0 from a function?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Can you post the unalterable function's prototype?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Zero and the null character are the same thing. NULL is slightly different, but it too evaluates to zero (even though it's only to be used for pointers). In short, the decimal value of 0 is the null character.



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

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    9
    im sorry, i found the problem....it was a stupid beginners mistake.

    sorry to waste peoples time.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  2. Help with yacc/compiler design/seg fault
    By trippeer in forum C Programming
    Replies: 1
    Last Post: 04-08-2005, 03:43 AM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM