0
why this code still runs as space is insufficient in malloc in c....???
#include<stdio.h> #include<stdlib.h> int main(){ int *x; x=(int*)malloc(1); for(int i=0;i<9;i++){ x[i]=i+10; if (x!=NULL){ *(x+2)=50;} printf("%d\n",x[i]); } return 0; }
3 Respostas
0
It seems to mess up whatever comes in first from stdin. Then gives x 8 bytes of data and continues.
https://code.sololearn.com/cyjdlkx88aDn/?ref=app