This is probably a stupid question but I've got no idea how to do this :/,
So in a hypothetical world, I've got 2 variable's (Both are 2) so if I would add them together (2 + 2 = 4 ) bt I want to code it in such a way that it becomes 22 so put them behind each other.
Could anyone explain this? I thought I could use something like this (see below) but it always returns 2, so if someone could explain it to me I would really appreciate it
int a = 2;
int b = 2;
int ab = 0;
void setup() {
 Serial.begin(9600);
}
void loop() {
 ab = a, b;
 Serial.println(ab);
}
Do you have the slightest idea about what the comma operator does, or are you just guessing?
It's one thing to try something that's merely wrong, it's another thing entirely to try something like "what could have possibly made you think that would work?"
nunofyourbusiness:
If you simply want to print a followed by b the void loop should be:
Serial.print(a);
Serial.println(b);
delay();
This would make it a 22 if your vairables are 2 and 2; it would be a 35 if a is 3 and b is 5, etc.
No wanted to make it into one single variable so I could use it for something like delay(); but thank
AWOL:
Are you looking for int c = (a * 10) + b;
Yes that was exactly what I was looking for although I should've been able to think of something like that but I guess not, thank you so much!
Jiggy-Ninja:
Do you have the slightest idea about what the comma operator does, or are you just guessing?
It's one thing to try something that's merely wrong, it's another thing entirely to try something like "what could have possibly made you think that would work?"
Yes I know a bit about how it works but I felt like I had to show how it would logically work in my head but I shouldn't have its only confusing people, my fault.