Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

1
  • 1
    1) c_str() is no replacement for toCharArray(): your first example fails to compile with “error: invalid conversion from ‘const char*’ to ‘char*’”. Of course, if you only need a const char *, then c_str() is to be preferred. 2) In terms of code size, snprintf() is a very inefficient way of copying a string. 3) No need to subtract one from sizeof(buf) in the second argument to snprintf(). Commented Mar 20, 2017 at 18:46