daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Dec 15th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int **a;
  2.  a = (int**)malloc(10 * sizeof(int *));
  3.  for (int i = 0; i < 10; i++)
  4.      *(a+i) = (int *)malloc(10 * sizeof(int));
  5.    
  6. for (int i = 0; i < 10; i++) {
  7.     for (int j = 0; j < 10; j++) {
  8.         **a = 1;
  9.          (*a)++;
  10.     }
  11.     a++;
  12.  }
  13.    
  14. int rows = 10, cols = 10
  15.  int **a;
  16.  // don't cast the return value of malloc
  17.  a = malloc(rows * sizeof(*a));
  18.  for (int i = 0; i < rows; i++)
  19.      a[i] = malloc(cols * sizeof(**a));
  20.  
  21. ...
  22.  
  23. for (int i = 0; i < rows; i++) {
  24.     for (int j = 0; j < cols; j++) {
  25.         a[i][j] = 1;
  26.     }
  27.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top