i have this code :
int main(int ac, char **av)
{
char *str = malloc(sizeof(char) * 1024);
if (str == null)
return (-1);
if (av[0] != null) {
strcpy(str, av[0]);
printf("%s\n", str);
}
return (0);
}
i often hear that when i do malloc of sizeof 1024 it's ugly or not a good way to allocate memory, but from what i've learned from my researchs 512 or 1024 for examples are optimized for the processor to do its calculation, so what should i do when i don't know the size of the string i need to handle ? ps: i know in the situation above i could do a strlen of av[0] it's just an illustration of my question.