Question: What do I need to type in the input for this code to get a segmentation fault. keys.clear(); pos = temp.find( ); string temp2 =

What do I need to type in the input for this code to get a segmentation fault.

keys.clear();

pos = temp.find(" ");

string temp2 = temp.substr(pos+1);

stringstream ss(temp2);

string token;

while(getline(ss, token, ' '))

{

keys.emplace_back(token);

}

cout << "OK" << endl;

}

else

{

cout << "ACCESS DENIED" << endl;

}

}

else if(input.find(f) != string::npos)

{

size_t pos = input.find(a);

string user = input.substr(pos+13);

if (find(occupants.begin(), occupants.end(), user) != occupants.end())

{

occupants.erase(std::remove(occupants.begin(), occupants.end(), user), occupants.end());

cout << "OK" << endl;

}

else

{

cout << user << " NOT HERE" << endl;

}

}

else

{

cout << "ERROR" << endl;

}

}

return 0;

}

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!