I want to ask if the following idea is possible:
I would like to use the variables names and their values stored in the file as follows:
tcmb = 2.73
outmap = output/all_skies_map.fits
I would like to read the file and store those values (i.e. tcmb = 2.73 store the value 2.73 in a variable called tcmb or for instance:
outmap = output/time_ordering_information.fits
, i want to save the last part:
time_ordering_information.fits in an string variable called outmap
)
Is that possible?, Ok what i have done so far is:
ifstream input(inifile.c_str());
char line[4048];
char *var = NULL;
char *value = NULL;
int cnt = 0;
while (!input.eof()){
input.getline(line, 4048);
if (input.eof())
break;
sscanf(line,"%s %*c %s \n", var, value);
if(strstr(var, "clsf" ) == var){clsfile = value; ascii=false;}
if(strstr(var, "map" ) == var){fname0 = value; ascii=false;}
if(strstr(var, "poin" ) == var){pointing = value; ascii=true;}
if(strstr(var, "angle" ) == var){angle_bol = value; ascii=false;}
if(strstr(var, "outcrossc" ) == var){fname1 = value;}
if(strstr(var, "outstokes" ) == var){fname2 = value;}
if(strstr(var, "outmap" ) == var){fname3 = value; ascii=true;}
if(strstr(var, "outoi" ) == var){fname4 = value;}
if(strstr(var, "velo" ) == var){velo = atof(value);}
if(strstr(var, "bgal" ) == var){bgal = atof(value);}
if(strstr(var, "lgal" ) == var){lgal = atof(value);}
if(strstr(var, "tcmb" ) == var){tcmb = atof(value);}
if(strstr(var, "freq" ) == var){freq = atof(value);}
if(strstr(var, "poin_m" ) == var){poin_m = atoi(value);}
if(strstr(var, "max_l" ) == var){max_l = atoi(value);}
if(strstr(var, "nskies" ) == var){nskies = atoi(value);}
cerr << var << endl;
cnt++;
}
input.close();
But i get Segmentation fault (core dumped) error when i try to run the entire code, i know that is crashing at this point because i put outputs after and before this piece of code.