Hey, I came across a problem that I can't think of how to solve. I have n = 3 which is how many arrays there are and then I have k = 5 which tells me how many elements there are in the array. So my text file is :
3 5
4 7 3 5 8
8 9 7 8 6
5 4 6 7 6
This is what I have so far. Not much. The only thing I know is I need to use 2 loops. Or maybe the second is supposed to be a while?
What you’re trying to achieve is commonly known as bidimensional array.
If you are attending some course, your teacher should have explained them.
To get a bidimensional array, you can use different syntaxes:
1 2 3 4
int myarr[10][10]; // array of 10 arrays of 10 ints
int *myarr[10]; // array of 10 pointers to int
int **myarr; // pointer to pointer to int
int (*myarr)[10]; // pointer to array of 10 ints
When you pass them to a function, you need to chose the correspondent syntax.
Ex.:
declaration function prototype function call
------------------ -------------------------- ---------------
int myarr[10][10]; void func(int myarr[][10]); func(myarr);
int *myarr[10]; void func(int *myarr[10]); func(myarr);
...
To cut a long story short, your question admits multiple answers: please provide further details.