Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. char ** 2dArray= NULL;
  2. int k = 0;
  3. int j = 0;
  4.  
  5. do{
  6. k++;
  7. for (int i= 0; i<10; i++){
  8. j++;
  9. 2dArray=(char**)realloc(2dArray, (j+1)*10*sizeof(char*));
  10. 2dArray[j-1]=(char*)malloc(10 *sizeof(char));
  11. ....
  12. }
  13. }while(k<3)
  14. // free the memory
  15. for (int l = 0; l < j; l++){
  16. if (2dArray[l] != NULL)
  17. free(2dArray[l]); // here I get the error!
  18. }
  19. free(2dArray);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement