FWIW -
this generates a compiler warning:

for(int i = 0;i<strlen(str);i++)

unsigned and signed mismatch

this does not generate a compiler warning

for (int i = o;i<lstrlen(str);i++)

size_t is really UINT and int is signed. will definitely cause problems if you mix 'n' match types. It's a no-no.