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

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -