Hallo dEVooXiAm,
why do you use strncpy? why not just do *(pdest + 1) = 0; ?
Because *(pdest + 1) = 0; makes absolutely no sense to me!
I'm a very reluctant novice C programmer.
*(pdest + 1) = 0; is what's wrong with C, IMHO.
Programming statements should be easily understood, as they are just the means to an end, not the end in itself. I mean that more effort should be in the design of the software, the user interface, looking at how it is to be used, and by whom, rather than getting the code syntax right.
Presumably (*pdest + 1) = 0; would mean something completely different. That's the sort of easy-to-get-wrong syntax which has no place in a modern computer language. The code should be obvious what it is trying to achieve, the language clear and unambiguous, mistakes easily spotted.
C was good for simple programs on computers with tiny memories, but things have moved on. Programs are more complex, computers more powerful. In a program of 10 lines, each line gets a lot of attention. In a program of 100,000 lines, each line is of lesser importance compared to the whole.
To me a=a+1 is 'english', understandable by anyone who has done algrebra or beginners computer programming.
a++ is not.
It might mean that the computer can map it to the assembly language better, but I want the compiler to do that for me.
It also means that the number of statements can be reduced, 1 line instead of 3 perhaps, for some coding examples. IMHO, this is not a good thing as it introduces the potential for more subtle errors and requires more knowledge on the order the line is to be processed in.
I don't mean anything personal by this rant. I will never be a C programmer, and am impressed by anyone who is good at it, but maybe it's time for a new generation of languages/compilers which allow easy to understand code to be written, but run as fast as C.
- Frink