Skip to content

String + operator does not work with ints [imported] #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cmaglie opened this issue Nov 15, 2012 · 0 comments
Closed

String + operator does not work with ints [imported] #304

cmaglie opened this issue Nov 15, 2012 · 0 comments
Labels
Type: Invalid Off topic for this repository, or a bug report determined to not actually represent a bug

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

This is Issue 304 moved from a Google Code project.
Added by 2010-07-27T20:26:20.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.
Closed (Invalid).

Original labels: Type-Defect, Priority-Medium, Component-Core

Original description

What steps will reproduce the problem?
This code:
void loop() {
String stringOne = "this";
for (int charNum = 0; charNum < stringOne.length(); charNum++) {
char thisChar = stringOne.charAt(charNum);
Serial.println("Character " + charNum + " of " + stringOne + " is " + thisChar);
}
}

can be fixed by casting charNum to a String.

What is the expected output? What do you see instead?
Expected:
String character functions:
Character 0 of this is t
Character 1 of this is h
Character 2 of this is i
Character 3 of this is s

Got:
StringCharacterFunctions.cpp: In function 'void loop()':
StringCharacterFunctions:25: error: invalid operands of types 'const char*' and 'const char [5]' to binary 'operator+'

@cmaglie cmaglie closed this as completed Nov 15, 2012
tbowmo pushed a commit to tbowmo/Arduino that referenced this issue Jul 14, 2016
Core functions for Vcc and frequency readings
@per1234 per1234 added the Type: Invalid Off topic for this repository, or a bug report determined to not actually represent a bug label Jul 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Invalid Off topic for this repository, or a bug report determined to not actually represent a bug
Projects
None yet
Development

No branches or pull requests

2 participants