From fb1abe737ed23c57a3208d603933dd68138ad022 Mon Sep 17 00:00:00 2001 From: Mimmo La Fauci Date: Fri, 8 Feb 2013 19:21:46 +0100 Subject: Added function on WString class to export char ptr --- cores/arduino/Print.cpp | 7 ++----- cores/arduino/WString.cpp | 4 ++++ cores/arduino/WString.h | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'cores/arduino') diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index 53961ec..e087313 100755 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -53,11 +53,8 @@ size_t Print::print(const __FlashStringHelper *ifsh) size_t Print::print(const String &s) { - size_t n = 0; - for (uint16_t i = 0; i < s.length(); i++) { - n += write(s[i]); - } - return n; + write((const uint8_t*)s.c_str(), s.length()); + return s.length(); } size_t Print::print(const char str[]) diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp index c6839fc..d05037b 100644 --- a/cores/arduino/WString.cpp +++ b/cores/arduino/WString.cpp @@ -642,4 +642,8 @@ long String::toInt(void) const return 0; } +char* String::c_str() const +{ + return buffer; +} diff --git a/cores/arduino/WString.h b/cores/arduino/WString.h index 947325e..ec6cead 100644 --- a/cores/arduino/WString.h +++ b/cores/arduino/WString.h @@ -169,6 +169,7 @@ public: // parsing/conversion long toInt(void) const; + char* c_str() const; protected: char *buffer; // the actual char array -- cgit v1.2.3-18-g5258