davidd
Joined: 30 Sep 2010 Posts: 38
|
passing pointers question |
Posted: Sat Feb 20, 2016 6:49 pm |
|
|
Hello All,
I have constructed a simple function:
Code: |
void dec_to_2digit(int16 *tensdigit, int16 *onesdigit, int8 dec_number){
if (dec_number >= 10){
for (*tensdigit = 0; dec_number >= 10; dec_number -= 10) *tensdigit++;
}
else *tensdigit = 0;
*onesdigit = dec_number;
//even tried this -> *tensdigit = 3;
return;
}
|
when I call it using :
Code: |
dec_to_2digit(&tens, &ones, 65);
printf("tens %u, ones %u\n\r", tens, ones);
|
ones is 5,
tens is Always 0.
I even tried forcing a value into *tensdigit, and It reads back 0.
ver 5.045
Any help is very appreciated.
Davidd |
|