C :: Automatic Declaration Of Array Variables
Jul 14, 2014I have some files:
file1: 1000x500 array of numbers
file2: 2000x600
file3: 300x5000
...
I would like to automatically declare array variables of myarray1, myarray2, myarray3... that reads the numbers from files:
Code:
for (i1=0; i1<nrows; i1++)
{
for (i2=0; i2<ncolumns; i2++)
{
fscanf(filename, "%lf", &y);
myarrayX[i1][i2]=y;
}
}
nrows and ncolumns can be passed from a config file. Also I can cat all files into a single filename. However, the difficult part is:
How to declare different myarrayX automatically ? (A workaround is to declare a huge 3d array but I do not want to do this).