00001 #ifndef __read_file_h__ 00002 #define __read_file_h__ 00003 00004 #ifdef __cplusplus 00005 extern "C" { 00006 #endif 00007 00008 /* reads a file, determines the number of rows and columns 00009 and puts the values in the 2-dimensional data array of type double**. 00010 Space for data is dynamically allocated, declare it in the calling 00011 program as: double** data=0 00012 Make sure to remember to deallocate the memory for data 00013 when you have finished using it! (using data_dealloc) 00014 00015 input: filename: a string containing the filename. 00016 data: pointer to a two-dimensional array. 00017 00018 output: pnrow: pointer to nrow, the number of rows. 00019 pncol: pointer to ncol, the number of columns. 00020 00021 Call using e.g. read_file("energy.txt",&data,&nrow,&ncol); 00022 */ 00023 void read_file(char* filename, double*** data,int* pnrow, int* pncol); 00024 00025 /* free the data array 00026 Call using e.g. data_dealloc(&data,nrow) 00027 */ 00028 void data_dealloc(double*** data,int nrow); 00029 00030 void goto_nextline(char** part); 00031 00032 #ifdef __cplusplus 00033 } 00034 #endif 00035 00036 #endif