Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The last week I saw at least three questions where people were confused about the differences between char * and std::string or made some related mistakes.

Don't get me wrong, I don't have a problem with this, I just don't get the exact reason for this. Maybe it was just a coincidence.

share|improve this question

closed as primarily opinion-based by gbjbaanb, MichaelT, Dan Pichelman, durron597, Bart van Ingen Schenau Aug 6 '15 at 11:33

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

It wasn't confusion on my part but dealing with strings (and all their variety) in C++ made me want to go work in a different language. – Ken Henderson Nov 27 '10 at 21:49
This question should only be tagged as C++ as there is no such confusion in C since C does not have an std::string. – Brian R. Bondy Nov 28 '10 at 0:46
up vote 8 down vote accepted

Given that things like

std::string myString = "Hello, world!";

are perfectly valid, it seems rather obvious to me why there is confusion.

share|improve this answer
yet that same construct in other languages with primary string types doesn't cause confusion at all. – gbjbaanb Aug 5 '15 at 7:43
But most languages don't have two different string types to confuse beginners. – Simon B Aug 5 '15 at 10:13

Because they're both commonly known as "strings" in a language that has no real string type. It's very understandable that inexperienced coders would be confused by that...

share|improve this answer
+1 for no real string – Kugel Nov 28 '10 at 5:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.