principleMinor
C++ Strings vs. Character Arrays
Viewed 0 times
stringscharacterarrays
Problem
Why do you think it is that most C++ instructors teaching college level computer sciences discourage or even forbid using strings for text, instead requiring students to use character arrays?
I am assuming this methodology is somehow intended to teach good programming habits, but in my experience I don't see anything wrong with just using strings, and they are significantly easier to use and learn.
I am assuming this methodology is somehow intended to teach good programming habits, but in my experience I don't see anything wrong with just using strings, and they are significantly easier to use and learn.
Solution
Koenig and Moe's Accelerated C++ and Stroustrup's Programming: Principles and Practice Using C++ are using std::string and other components from the standard library from the start. If I remember correctly, they don't even present C arrays for Koenig and Moe and Stroustrup does it quite late in the book (perhaps even just in an annex).
That approach, qualified as modern, is the preferred one in my circles. The other approach, often qualified as historic, follows more closely how C++ evolved, but doesn't take advantage of "newer" (relatively, they are 15 years old now) development and doesn't teach what is practised now (at least on projects not encumbered with too much legacy) but 10 years ago (there is always a lag before being mainstream).
That approach, qualified as modern, is the preferred one in my circles. The other approach, often qualified as historic, follows more closely how C++ evolved, but doesn't take advantage of "newer" (relatively, they are 15 years old now) development and doesn't teach what is practised now (at least on projects not encumbered with too much legacy) but 10 years ago (there is always a lag before being mainstream).
Context
StackExchange Computer Science Q#1375, answer score: 7
Revisions (0)
No revisions yet.