fork(4) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void matriz_ponteiro(int *matriz, int linhas, int colunas) {
  5. int lin, col;
  6. for (lin = 0; lin < linhas; lin++) {
  7. if (lin != 0) printf("\n");
  8. for (col = 0; col < colunas; col++) {
  9. printf("\t%d", matriz[lin * colunas + col]);
  10. }
  11. }
  12. }
  13.  
  14. int main() {
  15. int mtr[3][4];
  16. int lin, col, cont;
  17. cont = 0;
  18. // armazenar o valor de cont em cada posição da matriz
  19. for (lin = 0; lin < 3; lin++) {
  20. for (col = 0; col < 4; col++) {
  21. mtr[lin][col] = cont++;
  22. }
  23.  
  24. }
  25. matriz_ponteiro(mtr[0], 3, 4);
  26. }
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
	0	1	2	3
	4	5	6	7
	8	9	10	11