#include "stdio.h"
int value = 1234567;
int val;
int val1;
int val2;
int val3;
int val4;
int val5;
int val6;
int val7;

void uint_to_str_leading( char* dst, unsigned int i, size_t size )
{
    char* pCurChar;
    if (size == 0) return;
    pCurChar = dst + size;
    *--pCurChar = '\0';
    while (pCurChar != dst) {        
        int digit = i % 10;
        i = i /10;
        *--pCurChar = '0' + digit;
    }
    return;
}

void int_to_str_leading( char* dst, int i, size_t size )
{
    if (size && (i < 0)) {
        *dst++ = '-';
        size -= 1;
        i *= -1;
    }
    uint_to_str_leading( dst, i, size);
    return;
}

int main(void) {
  char buffer[80];
  char str[20];
  uint_to_str_leading(buffer, value, 8); 
  strcpy(str, buffer);
  val = atoi(str);
  
  char stringValue[7]; sprintf(stringValue, "%d", value);
  
  val1 = (buffer[0]-48);
  val2 = (buffer[1]-48);
  val3 = (buffer[2]-48);
  val4 = (buffer[3]-48);
  val5 = (buffer[4]-48);
  val6 = (buffer[5]-48);
  val7 = (buffer[6]-48);
  
  printf("Sensor: %d\n", value);
  printf("\n");
  printf("Vals : %d %d %d %d %d %d %d\n", val1, val2, val3, val4, val5, val6, val7);
  
  return 0;
}