c++ - Why does this not tell me how long the vector of strings is? -
c++ - Why does this not tell me how long the vector of strings is? -
#include <iostream> #include <vector> using namespace std; int main () { vector<string> ss; ss.push_back("the number 10"); cout << ss.size(); homecoming 0; }
when run this, output 1. why not length of string?
it tell how long vector of strings is. length of vector means number of items in tt, in case 1.
to length of first item in vector, write cout << ss[0].size(); .
c++ vector
Comments
Post a Comment