Regarding the <string>, <cstring> thing, its my understanding that these are simply two different declarations of the same thing. For example, if one wishes C compilation using the old deprecated include convention, one would do this...
#include <string.h>
For modern C++ one would do this...
#include <cstring>
...and one would be able to use all the string primitives just like in c (after all ISO C++ includes the C Standard Library too), but one would also have access to the standard C++ library string class (STL implementation of basic_string).
For my C++ coding I typically do a #include <string.h>, even though it is deprecated (I don't know if that's the right word). The reason I do this is because I almost always use my own string class, which I developed over the course of a good many years, and it requires the string primitives in string.h, i.e., strlen(), strcpy(), etc.
Hope you don't mind if I add my own two cents here Lamblion. The kind of low level C buffer minipulation you are doing will kill your productivity. I am whole hearted in approval of knowing how to do all that kind of stuff with pointers, but I have to say that it will grind you right into the dirt. I wish I had some of the time back I did stuff like that over the course of my life. Actually, the reason I learned C++ was because stuff like that was eating me alive.
I program in C, C++, and PowerBASIC, and I've run into many occasions where I'd spend five or ten minutes doing some kind of string minipulation in PowerBASIC, that, when I tried to translate it to C took me a whole morning or afternoon. That's why I wrote my own string class.
Anyway, here is a PowerBASIC 32 bit console program with its output that does what you are asking...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#Compile Exe
#Dim All
Function PBMain() As Long
Local strLine As String
strLine = "KJV Jhn 3:16"
Print "strLine = " strLine
Replace "Jhn" With "joh" In strLine
Print "strLine = " strLine
Con.Waitkey$
PBMain=0
End Function
'strLine = KJV Jhn 3:16
'strLine = KJV joh 3:16
|
The above compiles to 11K, which would be somewhere in the neighborhood of 40-60K less than a C++ program using the Standard C++ Library String Class (its faster too).
So I'm in agreement with WebJose. That stuff will eat you alive!
However, I'm very sympathetic to what you are doing, because I do it all the time. I prefer to write tight compiled code, and I like small program size. If my string minipulation needs aren't too great in a program, I'll not include the C++ string class, because, like I said, it will add about 40 - 60K to your program. For most folks who use class frameworks, that's no big deal, but I do straight SDK, so its a big deal to me.