Pages: [1]   Go Down
Author Topic: integer to char  (Read 611 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

how can i convert Integer to char ??
Logged

Queensland, Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

See if anything in this thread helps:

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

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26485
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

strcat, but that's not the answer to your original question.
A char already is an integer.
It isn't an int, though.
Logged

"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.

Melbourne, Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 567
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
// 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);


}
Logged

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 632
Posts: 50182
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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".
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26485
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please, don't consider entertaining the possibility of allowing the thought to cross your mind of using String
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

-br
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

tweet should be in char
Logged

California
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3435
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 632
Posts: 50182
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Pages: [1]   Go Up
Jump to: