0

I want to know if it is possible to create an array that is composed of 2D arrays.

I have a function that modifies the content of a 2D array, in my program this function is called 2035 times. And each time the result is saved in the same 2D array. So of course I can have access to only the 2035 update of the 2D array.

  • Is it possible to have an array of 2D arrays?
  • Is there a way to save each 2D array?

2 Answers 2

3

An array of an array is called a "2D array", and it looks like this:

int arr[100][500];

i.e. an array containing 100 arrays, each of length 500.


An array of a 2D array is called a "3D array", and it looks like this:

int arr[2035][100][100]

i.e. an array containing 2035 2D arrays, each of dimension 100x100.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I guess starting to learn c by trying to implement AES makes you dumb ^^
@MFadil, Nothing like that. But you should start from simpler problems.
0
int** arr = malloc(sizeof(int*)*5);
int a;
for (a = 0; a < 5; a++){
    arr[a] = malloc(sizeof(int)*3);
}
arr[3][1] = 2;

This way to make a dinamic vector in C in easy mode... But this isn't organized.

:)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.