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

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

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -