The problem is of course, that assert always fails.Code:#include <assert.h> #include <malloc.h> void func1(int *val); int main() { int *val = 0; func1(val); assert(val != 0); } void func1(int *val) { int *newint = malloc(sizeof(int)); val = newint; }
Can anyone tell me why the pointer in main isn't being assigned to the variable on the heap?
Ah, is it because after the func1 returns, newint is pointing to garbage?