The following program is showing unexpected result
#include <stdio.h>
#include <stdlib.h>
int main()
{
char* num1;
num1 = malloc(100*sizeof(char));
num1 = "38462879";
printf("%s\n",num1);
num1[0]='5';
printf("%s\n",num1);
return 0;
}
I expect it to print the given string and then print the given string with the first letter replaced by 5 instead of 3 in the next line.
But it is printing the given string in first line and then the program is not going ahead.
Can you please help??