I tend to use strings all the time and rarely use C-
strings, just like references and pointers I used
references a ton more than pointers but now I am
using pointers and references about the same now
maybe more with pointers .
Can anyone give me an idea or example when it is
more appropriate to use a C-string over a string?
"Programmers are the Gods of their tiny worlds. They create something out of nothing. In their command-line universe, they say when it’s sunny and when it rains. And the tiny universe complies."
-Derek Powazek, http://powazek.com/posts/1655
MFC is just a wrapper for some Windows stuff. (MFC-Microsoft Foundation Class Library)
MFC's Cstring has a better performance, better interface, and no explicit casting (Cstring's LPCTSTR() vs std::string's c_str()) that's as far as I know (it has some other neat features string doesn't have)
"Programmers are the Gods of their tiny worlds. They create something out of nothing. In their command-line universe, they say when it’s sunny and when it rains. And the tiny universe complies."
-Derek Powazek, http://powazek.com/posts/1655
zodiac976 wrote:Can anyone give me an idea or example when it is
more appropriate to use a C-string over a string?
I think the general rule would be that if you can use C++ strings, use them. Hardware would be the limiting factor. If you're programming for a console or handheld or phone or something, you're probably going to be using C-strings, so that you have total control over how long the strings can be, and hence, how much memory they take.
Also, some handy functions like sprintf (which you can use for int to string conversion) require C-strings, so you might use a C-string for a second and then convert it back to a C++-string.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.