185k views
3 votes
A. True

b. False: the only difference between c-strings and string objects is how they are declared and internally stored. they are used exactly the same way.

1 Answer

3 votes
b. False. c-strings is a legacy data type to maintain backwards compatibility between C and C++. A c-string is simply a character pointer to a flat array of characters. And a c-string is generally terminated by a NUL character (NUL is a 0 value). A string object on the other hand is a fully defined object type and has operators assigned to it. For example, assume that a, b, and c are string objects with a having the value "Hello " and b having the value "World!". You can write the statement c = a + b; And after execution, the object c will have the value "Hello World!" But if you attempted to do the same thing with c-string, you would at best get a compile time error.
User Pravesh Agrawal
by
8.0k points