Hi, everyone
Please take a look at this piece of code. I'm allocating one byte for the first variable and another byte for the second one. However, it seems like the compiler allocates more (or I'm missing something). The program outputs both strings, even though their length is more the one byte.
void main() {
char* some1 = malloc(1);
sprintf(some1,"cool");
char* some2 = malloc(1);
sprintf(some2,"face");
printf("%s ",some1);
printf("%s\n",some2);
}
Please, could anyone spot some light on what's going on when memory is being allocated.