I would like to know if there is any way to dynamically allocate some memory when/before using a scanf. This would mean that there is no need to give a char *
a size when initializing it. Instead of this, the quantity of memory needed would be allocated depending on the size of the input string (which means: after having the input).
Currently I find no other solution than to allocate a specific quantity of memory before having the input, so before knowing the size of the input:
char str[10];
scanf("%s", str);
And I know this is not safe: if the input is longer than 10 characters, the program will write on unallocated memory, which can cause segfaults or stuff like that.