Int to char to string conversion

Hi,

I am using Teensy 4.1 for a UDP networking project, down bellow is an UDP send function appended by me.

My goal is to combine two integer values with a space between them and send it via UDP.

Variable 'line' is from a UDP template, I dont want to/can not mess with it, otherwise my UDP part could collapse, I just it as a given that 'line' is a string type

I have been struggling for a long time to do all the sequence I have described above. In my last attempt I tired to divide integers into digits and assign them as chars, and using indexing assign these to a string elements. However, my compiler does not give me any errors, my UDP receiver receives empty packets, and my Serial.println(line) does not show me anything at all. It seems my 'line' variable disappears. Any ideas on converting two integers to a continuous string? P.S Chanel and Chanel_value global variables are tested, the carry right values.

static void sendLine() {
  static String line;

  for (int i = 0; i<4096; i++){
   
    line[0] = char((Chanel[i]/1000)%10);
    line[1] = char((Chanel[i]/100)%10);
    line[2] = char((Chanel[i]/10)%10);
    line[3] = char(Chanel[i]%10);
    line[4] = ' ';
    line[5] = char((Chanel_value[i]/1000000)%10);
    line[6] = char((Chanel_value[i]/100000)%10);
    line[7] = char((Chanel_value[i]/10000)%10);
    line[8] = char((Chanel_value[i]/1000)%10);
    line[9] = char((Chanel_value[i]/100)%10);
    line[10] = char((Chanel_value[i]/10)%10);
    line[11] = char(Chanel_value[i]%10);
    
    Serial.println(line);

     if (!udp.send({10, 10, 16, 110}, kPort,
                  reinterpret_cast<const uint8_t *>(line.c_str()),
                  line.length())) {
      printf("[Error sending]\r\n");
    }
    printPrompt();
    delayMicroseconds(10);
  }
  
}

line[0] will have a value between 0 and 9(0x00 to 0x09), NOT the character representation of that(ASCII 0-9, value 0x30-0x39).
Is that your intent?

Why do you repeat this 4096 times? Are your arrays Channel and Channel_value has a 4096 elements in each? What the type of these arrays?

See, questions quickly evolve that require seeing more of your code, so sharing that is imperative. Please include your complete code, in code tags("code" button above message box).
Thanks

itoa() ?

Okay, I resolved this problem by taking out the string variable (I mentioned that I could not do it, but somehow I managed to), since there is not such thing as string type variable in C, it got a lot easier after that.