So I'm converting some (read: a lot of) legacy C code to C#, and discovered a substitue function used throughout the product to copy a char* replacing %FIELD% with a new value. For some reason it only converted the first occurance and I decided that was stupid and just changed it to a string.Replace in C# (which replaces all occurrances).
It appears at some point someone recognised this limitation. Did they fix the function? Nope. Create a new SubstituteAll function? Nope. They did this every time it didn't work properly.
for(j=0; j < 10; j++)
{
strcpy_s(temp, dest);
Substitute(temp, "%STARTDATE%", startDate, dest);
strcpy_s(temp, dest);
Substitute(temp, "%ENDDATE%", endDate, dest);
}
Will someone please shoot me?