Was working on a project and found myself needing a find and replace function that could handle both 64bit and 32 bit architectures, didn't require running on a class, and would be buffer-overrun safe.
Any improvements I could make to this code?
EDIT: Already found a problem LOL
if (replacementDifference) _tcscpy(currentReplacement + replacementLen, currentReplacement + lookForLen);
Can't use strcpy() on the same array. Replaced that with memmove();
memmove(currentReplacement + replacementLen, currentReplacement + lookForLen, sizeof(TCHAR)*(_tcslen(currentReplacement) + 1) );
Edited by Billy O'Neal, 30 December 2008 - 11:32 AM.