If you think that code is obfuscated, you should really learn to read code better. It''s nice and easy to follow, especially if you''re looking through the Standard at the same time.
How appropriate. You fight like a cow.
how to convert char to char * ?
quote:Original post by Anonymous Poster
I would probably say something about the same but I would rather use my own string class. Anyways the above is a stupid reply especially as the OP doesn''t know how C-strings work.
Yeah ok. You do your own thing and write your own String class. I''ll just stick with the stl version, which has been tried and tested by thousands of other programmers, and worked on for many more hours than you''ll put into your own string class.
Meanwhile you''ll spend time (hours? days? weeks?) writing - and over a greater period of time - debugging your own string. And after all that wasted time, will you really have something better?
The fact that the stl string hides annoying and error prone details about the implementation (such as null terminated char*) is a good thing, especially to someone new to a language. If they really want to they can come back and learn about the char* way later.
K, Jim Adams uses delete[] on strdup().
--
You''re Welcome,
Rick Wong
- sitting in his chair doing the most time-consuming thing..
--
You''re Welcome,
Rick Wong
- sitting in his chair doing the most time-consuming thing..
quote:Original post by OrangyTang The fact that the stl string hides annoying and error prone details about the implementation (such as null terminated char*) is a good thing, especially to someone new to a language. If they really want to they can come back and learn about the char* way later.
Yep. In fact, it is because of the fact that c++ is *not* learned in this manner that people write poor c++ code, abundant with buffer overruns.
Knowing about char* before std::string is NOT a good thing.
quote:Original post by OrangyTang
Using char* for strings in C++ is just plain stupid (or ignorant, take your pick ).
or backwards compatible.
oh wait, was that not one of the options?
quote:Original post by Anonymous Posterquote:Original post by OrangyTang
Using char* for strings in C++ is just plain stupid (or ignorant, take your pick ).
or backwards compatible.
oh wait, was that not one of the options?
Actually, it is. Just call .c_str()
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement