// vector::operator[]
#include <iostream>
#include <vector>
#include <string>
usingnamespace std;
int main ()
{
std::cout << "Give a person a name: " << endl;
//string inputString;
string inputString;
cin >> inputString;
std::string s(inputString);
std::vector<char> myVector( s.begin(), s.end() );
for ( char c : myVector )
{
std::cout << c << endl;
}
for (int i= 0; i < myVector[i]; i++)
{
std::cout << i << "\n";
}
std::cout << "Enter the index of the letter you want to change: " << endl;
int index;
cin >> index;
if(index > myVector.size())
{
std::cout << "index is outside the vector" << endl;
}
else
{
}
std::cout << " Enter the characters you wish to print on index: " << endl;
std::cout << "The person is named:" << endl;
return 0;
}
The program goes this far and stops so I can´t cin a number in index
[code]
std::cout << "Enter the index of the letter you want to change: " << endl;
int index;
cin >> index;
if(index > myVector.size())
{
std::cout << "index is outside the vector" << endl;
}
else
{
}[code]
This coder doesnt run at all and I can´t see the problem.