Are you going indeed to enter 1000 strings manually in the vector?:)
Also it is a good idea to define canstant names using letters of upper case. So instead of
#define max 10000.0
it would be better to write
#define MAX 10000.0
And it is not clear why max is defined as a float number instead of an integer.
Take into account that variable n was not declared in your program. So the program does not compile. Maybe you mean max instead of n.
As the vector is defined as an empty vector
vector<string> room_name;
that is it does not have elements then you may not use the subscript operator to enter values in the vector.
You could use method push_back instead the following way
vector<string> room_name;
room_name.reserve( n );
for ( int i = 0; i < n; i++ )
{
string s;
cin >> s;
room_name.push_back( s );
}
And instead of the loop you could use standard algorithm std::copy_n declared in header <algorithm>
#include <iostream>
#include <string>
#include <iterator>
#include <algorithm>
#define N 2
int main()
{
std::vector<std::string>room_name;
room_name.reserve( N );
std::copy_n( std::istream_iterator<std::string>( std::cin ), N,
std::back_inserter( room_name ) );
for ( const std::string &s : room_name ) std::cout << s << std::endl;
return 0;
}
If to enter strings
my_room
your_room
then the program will output them from the vector
my_room
your_room