String data type and char array in C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

String data type and char array in C++

Is it useful to include String header in a C++ file to store string data instead of using a character array if you're not going to perform and String operations?

26th Apr 2017, 9:35 AM
Nana Osei
Nana Osei - avatar
2 Answers
+ 8
In most C++ compilers, std::string is already included in <iostream> header. To be honest, since strings are character arrays, it's been quite a long time I haven't declared char arrays. Most of the time, I just do strings.
26th Apr 2017, 12:32 PM
Hatsy Rei
Hatsy Rei - avatar
+ 5
I don't think so, but it is always handy if you're not sure if you're going to do it in the future.. Also use the option for only include when not already included. You probebly are going to do string man. somewhere so I would say just include it.
26th Apr 2017, 9:50 AM
Harm Zeinstra
Harm Zeinstra - avatar