2

I'm using MPLab C18 C compiler and getting a syntax error with this code:

hundreds = unsigned char((tick / 100));
tens = unsigned char((tick - (hundreds * 100)) / 10);
ones = unsigned char((tick - (hundreds * 100) - (tens * 10)));

tick is an unsigned int. What I'm attempting is to convert a three digit value over to three individual ASCII values by means of simple division and casting the whole number into my unsigned char variables.

It looks okay to me but I guess I'm missing something.

Ralf Stubner
  • 26,263
  • 3
  • 40
  • 75
Chef Flambe
  • 885
  • 2
  • 15
  • 35

1 Answers1

11

Casting is done in parentheses:

 hundreds = (unsigned char)(tick/100);
MByD
  • 135,866
  • 28
  • 264
  • 277