## Never mind! This programmer is goofy.

3 posts / 0 new
Author
Message

Loose nut in the programmer's chair.

When I pass a char to a function, the function always gets 0, zero, not a character, as opposed to "0". Not only that, but it was working earlier...

A scrap of code:

When it builds bs by setting bs[0] to bn and bs[1] to 0, it gets the character (Comes from a keypad). But when the function "SayWhat" builds bs by setting bs[0] to the parameter b and bs[1] to 0, it always sees b as a 0.

```void SayWhat(char b)
{
char bs[2];
bs[0] = b ;
if(bs[0] == 0) bs[0] = 'x' ; // so I can "see" it
bs[1] = 0 ;
LCDxy(1,0);
LCDWrite(bs);
}

char bs[2];
bs[0] = nb ;
bs[1] = 0 ;
LCDHome();
LCDWrite(bs);
SayWhat(nb);

```

You're right, I didn't tell you it's an xMega8E5, but what difference should that make? nb is still my character.

```		char b = Button() ;
char nb = b ;
if (b==ob)  nb = 0 ;
ob = b ;
```

Button just scans the keypad and figures out which button is pressed, returns 0 if none. Doesn't worry about if you press 2 together.

I built "SayWhat" to see what was really getting passed as the real function always gets 0. The chars from the keypad, that I can see in the first column of the LCD are '123456789*0#' as I press the buttons, but in the second column is always 'x'.

Where does it go?

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut.

0 is not '0' (the latter is 0x30). Surely you need some kind of binary to ASCII conversion? This might be as simple as just adding '0' to the passed value.