easy way to convert a string to a character array

barryjo:
An earlier post referenced an article explaining why not to use strings in the Arduino because of memory issues. So, does the arduino use a different C++ compiler and li9braries than would be used on a PC for example? When the Arduino compiles, I see the "gcc" compiler shown often. Isn't this the same compiler that Linux uses? What happens to the compiled code as I move a program from the Arduino to a PC?

I am just trying to understand.

Just semantics String class vs. C string...

Compilers may be run with settings that specify the Hardware requirements, that is a part of the Arduino IDE.

All of the C++ std libraries are not included/available in an attempt to compile for Arduino, for example.

This article was referenced earlier about the "evil of arduino strings"

Wrong! That article is about the evils of Arduino Strings. It says nothing about not using strings. In fact it specifically recommends using strings.

BulldogLowell:
For computers with 1) a large memory pool and 2) proper garbage collection things like String classes [not C strings] and Vectors are not a problem. All types of dynamic allocation are done every day on computers.

Well, you can't say "not a problem". It won't be a problem for a longer period of time, but it can still occur. Most people won't notice it, because they reboot once per day. Or they reboot when the computer gets "slow", not realizing that it's slow because it's thrashing. And it's thrashing because of memory usage. In this setting, rebooting is almost zero cost.

On the Arduino, there's just not enough room in 2K to avoid "memory issues" for non-trivial sketches. It manifests very quickly. In this setting, a frozen/misbehaving Arduino usually has a higher cost.

Lest you doubt, please review this well-documented phenomenon: check out the last 3 links here. Fragmentation on servers with gigabytes of RAM? Yes. Rebooting servers? Expensive.

The answer is always to get away from random-size, random-order, overlapping lifetime allocations: use pools (one kind of well-behaved dynamic allocation technique, undoubtedly used on servers) or C strings (statically allocated char arrays).

For the OP: Don't use the String class™. The solutions using C strings (i.e., char arrays) are very efficient and well-behaved.

-dev:
Well, you can't say "not a problem". It won't be a problem for a longer period of time, but it can still occur. Most people won't notice it, because they reboot once per day. Or they reboot when the computer gets "slow", not realizing that it's slow because it's thrashing. And it's thrashing because of memory usage. In this setting, rebooting is almost zero cost.

Sorry, I forgot about that... I'm on a Mac.