Hi
I have written this Program which create a list of books which is given by the User and i can't free the my_value at the end of program and get a lot of errors .
This is my Code
#include <stdio.h>
#include <stdlib.h>
int main(){
int n;
printf("Please Enter the Number of Books:\n");
scanf("%d",&n);
char **array=(char *) malloc((n+1)*sizeof(char *));
for(int i=0;i<n;i++){
array[i] = (char *)malloc(sizeof(char *));
}
for(int i=0;i<n;i++){
char *my_value=(char *) malloc(sizeof(char)*100);
printf("Please Enter the Name of the %dth Book:\n",i+1);
scanf("%s",my_value);
*(array+i)=my_value;
free(my_value);
}
for(int i=0;i<n;i++){
printf("\n The Book Nr.%d is %s \n",i+1,*(array+i));
}
for(int i=0;i<n;i++){
free(array[i]);
}
free(array);
return 0 ;
}