is "String" unique to arduino

i thought in C++ is it "string" with a lower case "s"

No.

C++ also supports Strings which are a different thing altogether than strings

what do i need to include to compile a "String"?

Nothing explicitly needs to be included. The compiler will do it all for you, but be aware that using Strings in a limited memory environment is not generally recommended

not an arduino program

on my laptop, using the gcc compiler, what do i need to include to compiler

String a;

vs

string b;
string b;

What is that line of code supposed to do ?

simply allocate a string variable.

#include <string>
#include <iostream>

using namespace std;

int
main()
{
   string SS;     // C++ STL string

   SS = "This is a string";

   cout << SS << endl;

   printf ("%s: %s\n", __func__, SS.c_str());
}

Yes. String is Arduino and (Arduino-like) thing.

It is the counterpart of the std::string.

If you must you could do:

using String = std::string;

but I'm not sure how "compatible" the two are.

arduino_new:

typedef String std::string;

doesn't appear to be that simple.

i did copy WString.h from the Arduino tree to my laptop environment and poke in to code that seems to minimally support the Arduino String class.

I think Arduino's String class is based on the Java's String class:
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html

The Wiring/Arduino IDE started as a fork of the Processing IDE, and I think they wanted to make an easy transition for people using Processing to program their computer to using Wiring/Arduino to program microcontrollers. Even though Wiring/Arduino languages are based on C++, they still tried to emulate the Java-based Processing language as closely as possible. In the end, I'm not sure the similarity to Processing is really as important as they expected it to be, but the API was already established.

thanks

can an Arduino "String" simply be replaced with "string" and compiled on a laptop using gcc?

Did you actually read that link I posted?

"can an Arduino "String" simply be replaced with "string" and compiled on a laptop using gcc?"

Probably not, but you can just give it a try and report back the results.

gcjr:
can an Arduino "String" simply be replaced with "string" and compiled on a laptop using gcc?

No, the API is different. Compare:
Arduino String class: String() - Arduino Reference

C++ string class: http://www.cplusplus.com/reference/string/string/

Java String class: http://www.cplusplus.com/reference/string/string/

There are differences in each one, but the C++ one is drastically different. I think the only function they share is c_str (which the Java class doesn't have).

Grumpy_Mike:
Did you actually read that link I posted?

This thread is about String, not null terminated char arrays.

Grumpy_Mike:
Did you actually read that link I posted?

it describes char arrays

zoomkat:
"can an Arduino "String" simply be replaced with "string" and compiled on a laptop using gcc?"

Probably not, but you can just give it a try and report back the results.

no joy

it describes char arrays

Yes that is what strings are with a lower case s. It means the same thing.

Grumpy_Mike:
Yes that is what strings are with a lower case s. It means the same thing.

see C++ "string" class (lower case "s")

In C a string is an array of ASCII characters terminated by a null.
Have you any argument with that statement?

Grumpy_Mike:
In C a string is an array of ASCII characters terminated by a null.
Have you any argument with that statement?

none whatsoever

but standard C++ also has a string class. so the following is valid

#include <string>
#include <iostream>

using namespace std;

int
main()
{
   char     cString []  = "my c string";
   string   SS          = "C++ STL string";

// SS = "This is a string";

   cout << SS << endl;

   printf ("%s: %s, %s\n", __func__, SS.c_str(), cString);
}

but the Arduino environment has String instead of string, as well as char *