Sorry, yes, I did mean sizeof().
Code:
string qa[][2] = {
{"What is your name?", "John"},
{"How many megabytes of RAM do you have?", "None of your business"},
// ...
};
for(string::size_type x = 0; x < qa.length(); x ++) {
if(qa[x][0] == question) {
cout << qa[x][1] << endl;
break;
}
}
->
Code:
string qa[][2] = {
{"What is your name?", "John"},
{"How many megabytes of RAM do you have?", "None of your business"},
// ...
};
for(string::size_type x = 0; x < sizeof(qa) / sizeof(*qa); x ++) {
if(qa[x][0] == question) {
cout << qa[x][1] << endl;
break;
}
}
Im found out how to put them into vectors but how do i look for substrings?
You could compare the value you're looking for with every string in the vector (a sequential search). Or maybe you could use the find algorithm: http://www.cppreference.com/cppalgorithm/find.html