Read size of data array when reading .txt data
Hi a newbie here (just started learning C two weeks ago). I like C as a fresh start. I have been using R and Matlab for most numerical analysis. But it takes a lot of times and CPU when I use a massive data. So that motivated me to take advantage of comiplier-based languages instead of interpreter-based ones.
Anyways, I would like to know how to let a program read the size of data array imported, and how to store values at the jth row and at the kth column into an j*k array, in C.
I tried the follwing codes to start with. I type the file name and let this program to read the file.. But it did not work. The values in the file are xx.xxx (double).
I am not sure why this does not work. No compiling errors, but no printout either.
/* define variables */
/* ask and get a file name to be read */
/* Show error message when the file doesn't exist in the current directory */
printf("Cannot open file\n");
So the first question is in what part I did wrong. and the second is that instead of assigning 6 and 2 in read_arr how can I let the program determine the size of array? I have many array data whose sizes are not the same. Eventually, i would like to loop this process and save the results, while I am doing something else.