Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,166 questions

40,722 answers

573 users

How to find array size in C++

2 Answers

0 votes
#include <iostream>

int main() {
    int arr[] = {1, 2, 3, 4, 5, 6, 7};

    std::cout << sizeof arr/sizeof arr[0];
 
    return 0;
}
     
     
     
     
/*
run:
   
7
      
*/

 





answered May 12, 2021 by avibootz
0 votes
#include <iostream>
#include <array>

int main() {
    std::array<int, 7> arr = {1, 2, 3, 4, 5, 6, 7};

    std::cout << arr.size();
 
    return 0;
}
     
     
     
     
/*
run:
   
7
      
*/

 





answered May 12, 2021 by avibootz

Related questions

1 answer 147 views
2 answers 74 views
2 answers 79 views
1 answer 95 views
...