I want to change the contents of the char pointer after allocating dynamic memory, is it possible? If not, why? My program throws a run-time error.
#include <stdio.h>
int main()
{
char * str = (char *) malloc (10 * sizeof(char));
str = "Hello";
str[2] = 'L'; // here the program throws run time error
printf("%s", str);
return 0;
}