I have a vector string :
vector <string> name[20][100];
I want to input to name[0][0], but getline is not working. My code :
cin.getline(name[0][0], sizeof(name[0][0]))
How to fix it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your first problem is that you are declaring a three-dimensional structure. I suspect you intended only two levels. The next problem is that you are using
std::basic_istream<…>::getline, which relies on you preparing buffer space in advance (which you are not doing). The free-function form,std::getline, is easier and safer: