I have a confusion with the following program
#include<stdio.h>
void main()
{
char *string;
string = (char *)malloc(5);
string = "abc"; // <<<<<<<<<< why *string="abc" is not working. How string = "abc" is working?
printf("%s", string);
}
But the same program with integer is working
char *i;
i=(int *)malloc(sizeof(int));
*i=4; <<<<<<<< this is working fine
printf("%d",*i);