Guest User

Untitled

a guest
Dec 15th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment