Difference btw Array of Char and String in c++?

Guys i want to know what is the difference between array of character and string in c++?
We have some library functions for string which are applicable to string and array of char as well.So want to know why was string used and included if they are same?
if they are not same please let me know some simple program in which we will be bound to use string or array of char.
Want early reply.
They are not the same. In C, array of char was the way to represent strings, therefore it is often called a c string. When you use a string literal like "abc" you get a c string.

In C++ the class std::string was added. std::string has a non-explicit constructor that takes a c string as argument and this makes it possible to pass a c string to a function that expects a std::string. In such cases the std::string constructor is implicitly invoked to construct the object.

std::string is often used instead of c strings because they are easier to use.
Want early reply.

Want pony.
Last edited on
Topic archived. No new replies allowed.