### Need some help with a project please!!

hey everyone. been trying to figure out this assignment but cant quit get it.
what i need to do is open a given txt file and read it its contents and place them into a vector.
the practice file is this:
9 John 3 Jane 7 Tom 2 Sam
6 Tom 1 Nicole 5 Tom
4 Jane 8 Ben

i need to place the names in the file into a vector in the order of the number in front of them. so it should look like this when i cout the vector contents:
nicole
sam
jane
jane
tom
tom
tom
ben
john

the code that i have written so far does this:
9
John
3
Jane
7
Tom
2
Sam
6
Tom
1
Nicole
5
Tom
4
Jane
8
Ben

i have counted through the vector and found that there are 9 names in the file. then i created a new vector called "names" that has a size of 9. my idea is to count through the original vector "v" and check at each position of v[i] for the number 1 (which i assigned to the character x). so if v[i] == x then i want the code to take the string after that character, v[i+1] and push that string into the new vector "names" using names.push_back().

the code in bold is where im having trouble. i believe it is because the vector v is in strings and i need to convert it to integers before i can compare my first condition of x < v.size() but i dont know how to do this.

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980`` ``````#include #include #include #include #include #include #include using namespace std; void fill_vector ( vector &v ); void print_vector ( vector names ); int count_names ( vector v ); int main() { vector v; string s; fill_vector(v); int num_names; num_names = count_names(v)/2; cout << "number of names " << num_names << endl; vector names[num_names]; int x = 1; while ( x < v.size() ) { for ( int i = 0; i < v.size(); i++ ) { if ( v[i] == x ) { names.push_back ( v[i + 1] ); break; } } x++; } print_vector(v); return 0; } void fill_vector ( vector &v ) { string s; ifstream fin; string input = "toy_names.txt"; fin.open ( input.c_str() ); fin >> s; while ( !fin.eof() ) { v.push_back ( s ); fin >> s; } } void print_vector ( vector names ) { for ( int i = 0; i < names.size(); i++ ) cout << names[i] << endl; } int count_names ( vector v ) { int counter = 0; for ( int i = 0; i < v.size(); i++ ) { counter++; } return counter; }``````