I have a problem when I am trying to free memory at the end of my program. It breaks all the time. Can you tell me where is the problem please?
int main() {
char* word = NULL;
int i = 0;
char str1[12] = "oko";
while (str1[i]) {
str1[i] = tolower(str1[i]);
i++;
}
printf("%s", str1);
word = (char *)malloc(strlen(str1) + 1);
word = str1;
printf("%s", word);
free(word);
system("pause");
return 0;
}