-
Memory Leak
Would this cause a memory leak or cause any other problems?
Code:
char *TestDecrypt(char *pText)
{
char pText2[1024];
strcpy(pText2, pText);
for(unsigned int i=0; i<strlen(pText); i++)
{
pText2[i]--;
}
char *strTextReturn = pText2;
return strTextReturn;
}
-
You're returning a local variable which will sooner or later become trashed.
try passing TWO char arrays, one to keep the new stuff:
Code:
char *TestDecrypt(char *dest,char *pText)
{
char pText2[1024];
strcpy(pText2, pText);
for(char *buf=dest,unsigned int i=0; i<strlen(pText); i++,buf++)
{
*buf=--pText2[i];
}
return dest;
}