int main() { int *p; p = (int*)malloc(sizeof(int)); p++; printf("%d",*p); p--;free(p); return 0; } could explain why program produces error when free(t) executed ? noticed program doesn't give error when printf("%d",*t); missing.
first declare t;
and don't free(t);it integer variable. free(p); pointer allocated memory.
or-
may wrote t instead of p in program did not declared t.
edit
but if chage t p
printf("%d",*p); will give undefined behaviour because in program have not initialized p.
first initialize p.
Comments
Post a Comment