How to check whether vector is empty in C++

1 Answer

0 votes
#include <iostream>
#include <vector>
   
int main()
{
    std::vector<int> v1 = {7, 8, 9};
    std::cout << v1.empty() << "\n";

    std::vector<int> v2;
    std::cout << v2.empty();
 
    return 0;
}
     
     
     
     
/*
run:
     
0
1
     
*/

 



answered Dec 6, 2020 by avibootz
...