Dynamic Memory Allocation (cont)
Bad Example:int * vec, *new_vec;if ((vec=(int*) malloc(ARR_LNG*sizeof(int)))==NULL){ fprintf(stderr,”cannot allocate\n”); exit(1);}if ((new_vec=(int*)realloc(vec,NEW_ARR_LNG*sizeof(int)) ==NULL) { fprintf(stderr,”cannot allocate\n”); exit(1);}/* now, vec points to nowhere */