+ 1
C-string vs. String object
When is better to use a C-string (array of characters) instead of a string object?
2 ответов
+ 2
Well, using C-string can make a smaller and maybe faster program, because there are not necessary object libraries.. But it is not the main necessary effect today..
The next reason to use C-string can be your work in programmers team, where anothers use this way. Or use another libraries with functions required the C-string as a parameters., or returned value..And many older external libraries and APIs support only char[], and char* types . But , of course, the conversion methods between C-string and class string exist, for using these libraries this way...
You have to know, the C++ language takes over the char[]/char * from the older C language. into the own begin,, And the string object has been added into c++ later in newest versions..
So there is really plenty of libraries source codes and programmers experience in using char[] and char*.
But, when you create only your program, with new libraries using, the string object can be a good choice. It is a faster, simpler and more safety deal with strings..