ok this isnt my code its my cuz that im tryin to understand and make simpler....
i wanna know i have to do
molecular check;
and molecular temp;
Code:unsigned storeData(ifstream & ifs,vector <molecular>& m) { molecular check; //temporary to read in files string name; string formula; unsigned max(0); char ch; while(ifs>>name>> ch >> check.carbon >> ch >> check.hydrogen) { molecular temp; unsigned c = check.carbon; unsigned h = check.hydrogen; if(!exists(m,c,h))//if this is a new formula { temp.names.push_back(name); temp.carbon=c; temp.hydrogen=h; m.push_back(temp);//create this molecule and push it into the vector if(c>max) max=c; } else//check if this name already exists and if it doesnt push it back { //on the names vector for(size_t i=0;i<m.size();i++) if(m[i].carbon==c && m[i].hydrogen==h && !nameExists(m,name,c,h)) { m[i].names.push_back(name); } } } return max; }
if i put just molecular temp here
and run the program it gives me wrong output...Code:molecular temp; string name; string formula; unsigned max(0); char ch; while(ifs>>name>> ch >> temp.carbon >> ch >> temp.hydrogen) {
any1 know y i have to do molecular check and temp and not just do one temp outside the loop



LinkBack URL
About LinkBacks


