Hi,

I have a doubt while specifying the size in malloc().

int main()
{
char *str;
str = (char *)malloc(sizeof(char) * 256);
scanf("%s", str);
}

the above program will work fine, only if the inputed strings length is less than 256. Is there anything available, which can calculate the size dynamically?

so that irrespective of the length of the inputed string, my program should work fine.

regards,
Ashok