How to split a number into variables?

Status
Not open for further replies.

psmeets

Junior Member level 1
Joined
Apr 25, 2001
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
52
Hi,

I am working on a 3 digit counter and want to display a number, let's say '263'. This value is stored in a variable (word).

To display the number correctly I need to split this number into three separate variables.

e.g.
2 into var1
6 into var2
3 into var3


Can anybody help me with a piece of code of with a hint?

Thanks!

Patrick
 

unsigned int in_data;
unsigned char a,b,c;

a=in_dat%10;
b=((in_dat-a)%100)/10;
c=((in_dat-a-10*b)%1000)/100;
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…