Hi,
I was just wondering about this function I wrote:
Code:
/*Reverses a string*/
char *strrev(char *in_string) {
char *out_string;
int in_char,
out_char;
out_string = (char *) calloc(strlen(in_string), sizeof(char));
in_char = strlen(in_string) - 1;
for (out_char = 0; out_char < in_char+1; out_char ++) {
out_string[out_char] = in_string[in_char - out_char];
}
return out_string;
}
I never free the memory pointed to by out_string, but I can't, because I have to return that. Am I screwing up somewhere, or is the memory freed when the function returns?