Advertisement
abdullahkahraman

Char to String

Apr 13th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. unsigned char* returnString(unsigned char inputValue)
  2. {
  3.     static unsigned char processedString[4];
  4.     unsigned char firstDigitCounter = 0;
  5.     unsigned char secondDigitCounter = 0;
  6.     if (inputValue > 99)
  7.     {
  8.         while (inputValue > 99)
  9.         {
  10.             inputValue -= 100;
  11.             firstDigitCounter++;
  12.         }
  13.         while (inputValue > 9)
  14.         {
  15.             inputValue -= 10;
  16.             secondDigitCounter++;
  17.         }
  18.         processedString[0] = firstDigitCounter + 0x30;
  19.         processedString[1] = secondDigitCounter + 0x30;
  20.         processedString[2] = inputValue + 0x30;
  21.         processedString[3] = '\0';
  22.     }
  23.     else
  24.     {
  25.         while (inputValue > 9)
  26.         {
  27.             inputValue -= 10;
  28.             secondDigitCounter++;
  29.         }
  30.         processedString[0] = secondDigitCounter + 0x30;
  31.         processedString[1] = inputValue + 0x30;
  32.         processedString[2] = '\0';
  33.     }
  34.     return processedString;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement