Skip to content

Commit c1daf33

Browse files
committed
Added function on WString class to export char ptr
1 parent 12afe86 commit c1daf33

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

hardware/arduino/cores/arduino/Print.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@ size_t Print::print(const __FlashStringHelper *ifsh)
5353

5454
size_t Print::print(const String &s)
5555
{
56-
size_t n = 0;
57-
for (uint16_t i = 0; i < s.length(); i++) {
58-
n += write(s[i]);
59-
}
60-
return n;
56+
write((const uint8_t*)s.c_str(), s.length());
57+
return s.length();
6158
}
6259

6360
size_t Print::print(const char str[])

hardware/arduino/cores/arduino/WString.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,4 +642,8 @@ long String::toInt(void) const
642642
return 0;
643643
}
644644

645+
char* String::c_str() const
646+
{
647+
return buffer;
648+
}
645649

hardware/arduino/cores/arduino/WString.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class String
169169

170170
// parsing/conversion
171171
long toInt(void) const;
172+
char* c_str() const;
172173

173174
protected:
174175
char *buffer; // the actual char array

0 commit comments

Comments
 (0)