void LCDWriteNumber(int num) { char buf[7]; char i = 0; char j, k; char temp; if (num != 0) { if (num < 0) { buf[0] = '-'; num = -num; i++; } for (j = i; num > 0; j++) { buf[j] = num % 10 + '0'; num /= 10; } buf[j] = '\0'; k = (j - i) / 2 + i; while (i < k) { j--; temp = buf[i]; buf[i] = buf[j]; buf[j] = temp; i++; } } else { buf[0] = '0'; buf[1] = '\0'; } LCDWriteString(buf); }
|