6

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.

closed as primarily opinion-based by gbjbaanb, user40980, 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.

  • 1
    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
8

Given that things like

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

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

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

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...

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