Jan 6, 2004 #1 P 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
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
Jan 6, 2004 #2 klug Advanced Member level 1 Joined Jul 4, 2002 Messages 474 Helped 12 Reputation 24 Reaction score 7 Trophy points 1,298 Activity points 4,356 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;
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;