I want to copy a string with a terminating zero to another location and want to know how long the copied string has been. Efficiency is paramount. There is a function strcpythat can achieve this, but does not return how many copies are actually copied.
Of course, I could find out by simply calling strlenafter that to determine the length of the copied string, but that would mean repeating the characters in the string again a second time, although I strcpyhave to keep track of how many letters copy anyway. For performance reasons, I don't want such a second workaround.
I know that writing your own strcpywith a simple copy of char -by-char is easy, but I thought the standard library could apply magic that does strcpyfaster than a naive char -by-char.
So what is the best method for strcpyand get the number of characters copied without re-moving the line?
source
share