Question: DELETE THE 4-- D STRUCTS WITHOUT MAKING ANY MEMORY LEAK ! void get_state_data(state * st, ifstream & input,int states ){ string line; int i =

DELETE THE 4-- D STRUCTS WITHOUT MAKING ANY MEMORY LEAK !

void get_state_data(state * st, ifstream & input,int states ){ string line; int i = 0, pos_char=0; while(i < states){ pos_char = input.tellg(); getline(input,line); int space = 0; for (int j = 0; j < line.length(); j++) { char character = line[j]; if (character == ' ') space++; } if (space==2){ input.seekg(pos_char); //cout<<"pos_char "<>st[i].name>>st[i].population>>st[i].counties ; cout<<" " <

void get_county_data(int i, state * st, ifstream &input, county * c, int county_size, int &pos_char) { string line; int j = 0; while ( j < county_size){ pos_char = input.tellg(); getline(input,line);getline(input,line); int space =0; for (int g = 0; g < line.length(); g++) { char charac = line[g]; if (charac == ' ') space++; } if (space>2) { input.seekg(pos_char); input>>st[i].c[j].name>> st[i].c[j].population>> st[i].c[j].avg_income>> st[i].c[j].avg_house>> st[i].c[j].cities; cout<< st[i].c[j].name<<" " << st[i].c[j].population << " "<> st[i].c[j].city[k]; cout << st[i].c[j].city[k]<<" "; } cout<

state* create_states(int states){ state * st = new state [states]; return st; }

county* create_counties(state* s, int i){ county * c = new county [s[i].counties]; return c; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!