I recently developed a code, but this produces incorrect result, cause some characters are still left in the source file if the number of characters in destination file is less than the number of characters in source file
The '+' implies you want to read from the file as well as write to it. Not sure why you'd want to do that. Also, with that mode specifier the file is opened as text mode.
I see on the reference page linked above, "On some library implementations, opening or creating a text file with update mode may treat the stream instead as a binary file."
Perhaps that is the case for your compiler. However, I'd still recommend the use of the 'b' flag for binary mode instead.
One more comment. Your original post included statements for file rewind. But if all you ever do is simply open, copy and close, there is no need for rewind.