Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

passing two dimensional array to function in c

#include <stdio.h>
#include <stdlib.h>

#define ROWS 3
#define COLS 2

void fun1(int **, int, int);

int main()
{
  int array_2D[ROWS][COLS] = { {1, 2}, {3, 4}, {5, 6} };
  int n = ROWS;
  int m = COLS;

  fun1(array_2D, n, m);

  return EXIT_SUCCESS;
}

void fun1(int **a, int n, int m)
{
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      printf("array[%d][%d]=%d
", i, j, a[i][j]);
    }
  }
}
Source by riptutorial.com #
 
PREVIOUS NEXT
Tagged: #passing #dimensional #array #function
ADD COMMENT
Topic
Name
4+7 =