How do you define a static matrix with #define in C?
14,969
I'd guess you want to use it like follows :
#include <stdio.h>
#include <string.h>
const int matrix[3][4]=
{
{1, 5, 6, 7},
{4, 4, 8, 0},
{2, 3, 4, 5}
};
int main()
{
int i, j;
for(i = 0; i< 3; i++)
{
for(j = 0; j<4; j++)
{
printf("%d ", matrix[i][j]);
}
printf("\n");
}
}
Author by
Admin
Updated on June 04, 2022Comments
-
Admin almost 2 years
In the directive
#define
you can define a static array, but I couldn't understand how you can define a static matrix?. I would like to create a library of static matrices.Can anyone help me?