I have this code written:
Resident_x * infos_shorted; Residents=6; infos_shorted=(Resident_x *)malloc(Residents*(sizeof(Resident_x))); i=0; while ((infos_shorted+i)!=NULL){ printf ("%d\n", i); i++; } Although someone would expect that I have allocated 6 memory places, when I run it it keeps printing i 's until I terminate it manually.
Thats what I have done to find an answer to my main problem which is this:
I write :
Resident_x * infos_shorted; Residents=6; infos_shorted[i].height[8]=7; infos_shorted=(Resident_x *)malloc(Residents*(sizeof(Resident_x))); for (i=0; i<=Residents+4; i++){ printf ("%d %d\n", infos_shorted[i].height, i); } And I get the infos_shorted[i].height[8] printed correctly. How is that;