Hi everybody,
I followed the discussion and can mostly agree with all of you. And yes, of course everybody should understand how the old fashioned C-string work and that there are many pitfalls when you use it. We also need to know about the dangers when you use normal arrays in C and C++.
But, yes there is a big BUT (in my humble opinion). What year do we write now . Ahhh yes it's 2024. And when was C invented? I think in the 1970ies.
I first dealt with those strings in about 1990 and have written thousands and thousands of code lines. Coming originally from Assembler (couple of different micro processors), then Fortran-V, Pascal, Modula-2, C, C++ , JAVA and last but not least C#.
What I can't believe is, that nowadays, after 50 years from the invention of C, we still have to deal with those primitive Cstrings. Yes, I also agree, that Memory Management is a difficult thing and it cannot be guaranteed to run smoothly when you only have 2k of memory.
But nowadays, I expect sophisticated libraries, that work perfectly and give me as much functionality as I want, so I don't have to write stupid Cstring functions anymore to do basic stuff. I just need to know exactly:
- about the limitations of such a library
- to be absolutely sure, that calling functions from the library never crashes my program and never cause memory issues.
Knowing this, I as a programmer need to take care, that I use those libraries carefully, so I know what can go wrong and take precautions. Me as a programmer, I need to concentrate on the job at hand and what my program needs to do and not about "Array Index Overflows" and stuff.
And yes, before a program leaves the factory, extensive testing MUST be done not only by me, but also from different testers. Best is you have many quality gates.
So this was my opinion about that.
Michael