Code:
char* xstrncat(char* s1, char* s2, size_t len1, size_t len2)
{
s1+=len1;
while(len2--)
*s1++=*s2++;
return s1;
}
This is good c but it lacks readability. Am I the only person here who thinks that code as above should read like this...
Code:
char* xstrncat(char* s1, char* s2, size_t len1, size_t len2)
{
s1+=len1;
while(len2)
{
*s1=*s2;
++s1;
++s2;
--len2;
}
return s1;
}
I think virtually any compiler will produce the same assembly language for this so why go with the former over the more readable latter.