How to check whether array object is empty or not in C++

1 Answer

0 votes
#include <iostream>
#include <array>

int main ()
{
    std::array<char, 0> arr1;
    std::cout << (arr1.empty() ? "empty" : "not empty") << '\n';
    
    std::array<char, 5> arr2;
    std::cout << (arr2.empty() ? "empty" : "not empty") << '\n';
    
    return 0;
}
 
 
 
/*
run:
 
empty
not empty
  
*/

 



answered Jul 28, 2020 by avibootz

Related questions

1 answer 202 views
1 answer 169 views
1 answer 221 views
1 answer 196 views
2 answers 219 views
...