char to int

Hi every one,

I need some help for my school project. I need to convert a char to a string but I don't understant what I found on Google... :confused:

I need to convert the char name "firstpart" to string to send it to my HCI.

Can you help me ? I put my code below :wink:

Thanks

  if(rf95.recv(buf, &len))
            {
               message = (char*)buf;     //mon message est stocké dans cette variable

              Serial.print("message : ");
              Serial.println(message);

              char firstpart[3];
              firstpart[0] = message[0];
              firstpart[1] = message[1];
              firstpart[2] = 0;
              
              Serial.print("first : ");
              Serial.println(firstpart);

Gweno: I need some help for my school project. I need to convert a char to a string but I don't understant what I found on Google... :confused:

I need to convert the char name "firstpart" to string to send it to my HCI.

Your Post is confusing. Your title says "char to int" but your text says "char to string"

If you need to convert a char string to an int then use the atoi() function.

I can't imagine any reason to convert a char string to a String. It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. This can happen after the program has been running perfectly for some time. Just use cstrings - char arrays terminated with '\0' (NULL).

If you want more help please post the complete program.

...R