So you're saying that length is the wrong value? In that case, atPosition must also be the wrong value (since that is what you pass to the copyTo function as the length argument), in which case there's no way for us to tell what's going wrong without seeing more code.

"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)

"it"? Are you saying you set a break statement inside CopyTo and a watch on the variable "length" and found that "length" was 71? As far as I can see, there isn't any problem with your code (although it might be used incorrectly)

"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)

Well, how are you calculating the length of the string? If you're looking for a '\0', then you'd better make sure the array is initialized with nulls to begin with. You also should add one at the end when you copy (if the new string is shorter, you'll wind up with a longer length then you expect). Or perhaps you should store the length in the class.

"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)

pet peeve. The names of your local variables are really lame. They don't really designate what they refer to. For example, startPosition is only the start position for the first buffer assignment, and then you're incrementing it. I would choose a name like "begin" or "pos". You have a variable length, but it isn't really the length, it's the end position. Why not choose a name like "end" or "endpos"?

Finally, you say that the length of the destination is not right, but do you have a member function that returns the length? Can you provide the code for it? Does it just use strlen()? If so you're copyto might be overwriting the null terminator in the destination.

For example, there is so little in the way of testing the inputs, I can imagine a case where your end position is not the null terminator in the source string, (just a mid section in the source string being copied) and you're actually overwriting the null terminator in the destination string (say the destination is a length smaller than the source string). So you end up with a destination with no null terminator. When you call strlen against it, there's no telling when or where it will find a null byte. I bet this is what is happening actually...

The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.