string or char array?

My instructor in introductory programming is teaching us to use char[size] to hold strings instead of string. Is it better programming etiquette to use a char array instead of string type? I know string isn't a fundamental data type, and it's possible that is why we aren't going to learn it, or maybe learning char[size] for string is a way to introduce arrays for ease of learning later in the course. I was just wondering, if you program professionally, which is better to use in general?
Last edited on
Your instructor is probably following some prehistoric (that is, pre-1998) C++ teaching program. All good textbooks (Accelerated C++, C++ Primer, Programming Principles and Practice) explain strings first.

And yes, strings are better to use in general: see C++ Coding Standards, rule 77 "Use vector and string instead of arrays"
Last edited on
it depends. if you dont need to modify that string, use const char*, else use string to simplify your work and because you are programming in C++, not C.

Topic archived. No new replies allowed.