I need to find the mistakes in the following code and I'm not sure I found all of them.
1)
char *str;
str=(int*)malloc(10);
I'm not sure if its allowed to allocate Integer and convert it to char but the first mistake I see is that the memory was not freed.
same with :
2)
char *str;
str=(char*)malloc(10);
free();
The memory was not freed right - should be ( free(str);). and if it's in the same code with the previous one then we allocated another memory and didn't free the previous one.
Am I right ? I'm not sure if you can allocate integer and convert to char tho.
Thank you in advance.