I have something I don't understand.
Here is what I do :
float* test = (float*) malloc(4 * sizeof(float) );
And then I tried to do
test = 1.0; printf("%f\n",test);
And ... It worked...
I was waiting for a segmentation fault, but no and I don't understand why. I wanted to do this to verify that my array has been correctly allocated. I really didn't expected that, and maybe I miss something so I searched on the internet, and it seems that everybody get a segfault ... So I came here to ask. Thanks
What you caused is undefined behavior - in this case, it works as expected, but it's a terrible idea to rely on it in any way: compiler optimizations or changing the operating system might suddenly cause "weird" behavior. You should read more on this topic, though in a nutshell, with undefined behavior, the compiler is allowed to do whatever it wants.
I don't have enough knowledge to be sure, but I hypothesize that your Operating System prepared a whole memory page for your program. In Linux by default it is 4 KiB, and you accessed bytes up to 400, so there is still plenty of room. Thus, you might be accessing memory that is allocated for your program, as the operating system works with memory blocks not smaller than 4 KiB.