Go Down

Topic: integer to char (Read 668 times) previous topic - next topic

how can i convert Integer to char ??

See if anything in this thread helps:

http://arduino.cc/forum/index.php/topic,41352.0.html

do u know bro how to concatenation 2 characters ?
Val1[] = "aaaaa";
val2[] = "bbbbbb";
i want to show val1+vla2
do u know how?

AWOL

strcat, but that's not the answer to your original question.
A char already is an integer.
It isn't an int, though.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

aarondc

Code: [Select]
// you can cast it like this:


int i = 7;
char ch;

void setup() {

    Serial.begin(9600);
    ch = (char)i;

  Serial.println(i);
  Serial.printlin(ch);


}
Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

PaulS

Quote
// you can cast it like this:

Not a good idea, really. What happens if i is 12894 or -4582?

OP: You need to clarify what you want to do. Converting an int to a string is one thin (that makes sense). Converting an int to a char is another (that doesn't necessarily make sense).

It seems that you have two questions: 1-int to char?  Please use the function" itoa()"; 2-Adding two chars together? Please consider using" String".

AWOL

Please, don't consider entertaining the possibility of allowing the thought to cross your mind of using String
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

i use function that only take char variable
i want to make concatenation with them
int x=1;
char x="number1" ;

i want to print "number 1" in my fuction that only take char ......convert int to char done ....now i only have problem to  concatenation 2 char

billroy

It is not necessary to concatenate two things to print them out one after the other.

-br

i using it in Twitter Library to send tweets consists of 2 ( Number & text)

tweet should be in char

Arrch

It sounds like both issues you're having can be solved with a simple call to sprintf().

PaulS

Quote
tweet should be in char

No, it isn't. The tween is an array of chars that is NULL terminated, also known as a string (which is not the same thing as a useless St\ring).

Go Up