How to create an empty vector of strings in C++

1 Answer

0 votes
#include <iostream>
#include <vector>
#include <string>

int main() {
    // Create an empty vector of strings
    std::vector<std::string> vec;
    
    // Get the size of the vector
    std::cout << "The size of the vector is: " << vec.size() << std::endl;
}



/*
run:

The size of the vector is: 0

*/

 



answered Jul 21, 2025 by avibootz
...