void setup() {
// put your setup code here, to run once:
String myString;
myString="foo" + "bar";
}
void loop() {
// put your main code here, to run repeatedly:
}
There is a huge number of functions available to you for using character array; strcat() is only one of them. BTW, the String version of the same program is 3482 while the code above only generates 2012 bytes.
There is a huge number of functions available to you for using character array; *strcat()* is only one of them. BTW, the String version of the same program is 3482 while the code above only generates 2012 bytes.
Other than to demonstrate my confusion, no it really doesn't.
Well, we can't tell what you are confused about, how you determined that the code did not do what you want. The myString variable is assigned some value, but goes out of scope immediately, so how can you tell that it was assigned an incorrect value?
...isn't allowed. It doesn't compile. It has nothing to do with being assigned an incorrect value. BulldogLowell explained that adding a constant to a constant does not work and understandably so. I'd have to assume that compiler doesn't allow it because the concat is done prior to the assignment.
I don't think the reference helped in this case. It says "Combines, or concatenates two strings into one new String. The second string is appended to the first, and the result is placed in a new String". To me, at the time, "This is a string" and "This is a string as well" are strings. So concat("This is a string","This is a string as well"); should have worked. Now if the strings are constants and the compiler cannot take two constants, concat them in memory and place them in a string var that is a different story. The reference really doesn't explain it that deep.
freakdaddy:
I don't think the reference helped in this case. It says "Combines, or concatenates two strings into one new String. The second string is appended to the first, and the result is placed in a new String". To me, at the time, "This is a string" and "This is a string as well" are strings. So concat("This is a string","This is a string as well"); should have worked. Now if the strings are constants and the compiler cannot take two constants, concat them in memory and place them in a string var that is a different story. The reference really doesn't explain it that deep.
so, the right side of the assignment operator has to be calculated before the assignment can be made, right?