Diffrence between values | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Diffrence between values

what is diffrent between an array of char and a string? which one is better to use?

30th Nov 2018, 5:05 AM
Saman Kamrany
Saman Kamrany - avatar
2 Answers
+ 5
The std::string class contains an array of characters, but its advantage is that it automatically manages that array for you and provides lots of helper functions for it, making it a lot easier to use than a plain character array. Here are some articles regarding the topic: https://www.geeksforgeeks.org/char-vs-stdstring-vs-char-c/ https://embeddedartistry.com/blog/2017/7/24/stdstring-vs-c-strings https://techdifferences.com/difference-between-character-array-and-string.html
30th Nov 2018, 5:57 AM
Shadow
Shadow - avatar
+ 1
string is not a type in cpp, its a object witch means you can use many built-in functions that comes with it!
30th Nov 2018, 5:59 AM
Mohammad Rezazadeh