So I use the following function: int main(argc, char*argv[]).... along with an ifstream to pull data from a txt file and stored it into an a multidimensional array. How do I pass the data from this array to another function?
int func2(int p[], int width)
{
// p[2][3] = 1; // no good anymore, 1D array
p[ (2*width) + 3] = 1; // the 1D apprach to do the same thing
/* It's worth noting here that the above (y*width)+x calculation is basically what
MD arrays compile to anyway. The compiler just hides it from you with MD arrays.
Or at least it's true with Straight Flavor MD arrays. Other flavors are more sinister.
*/
}
//...
int evil[4][5];
func2(evil[0],5); // ugly
The thing is that their function is: int func2(int p[], int width). My issue is that I'm using int main(argc, char*argv[]) to pull data from a file and storing it in an array. My issue is making this array available for other functions to use. Am I being confusing?