Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
I am trying to read the data from a file and store into a 2D array(the file contains 540000 values), but i m facing memory issues. Then my friend suggested to create a dynamic 2D array, i thought thats simple but when i searched for the code on web, i was in vain and hardly implement those stuff.
Can anyone please tell me how do i declare,intialize and access a 2D array dynamically.
The code which i tried to implement is below, but i am ending up in errors
FILE *fp; //file pointer for reading a file
DataLat=new double; // 2-D array for holding all the file values
int row=0, col=0; // row column and column declaration, used in 2-d array
fp = fopen("lat.txt", "r");
if ( fp == NULL )
puts("Unable to open the file");
exit(1); //terminate program
fclose( fp );