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

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,990 questions

51,935 answers

573 users

How to get the size of array of structs in C++

1 Answer

0 votes
#include <iostream> 
 
using namespace std; 
   
struct Test { 
    float book_price; 
    int book_tax; 
}; 
   
int main() 
{ 
    Test arr[] = { 
        { 4, 6 }, 
        { 1, 7 }, 
        { 11, 5 }, 
        { 8, 6 }, 
        { 2, 3 }, 
        { 7, 5 } 
    }; 
 
    cout << sizeof arr / sizeof arr[0]; 
     
    return 0; 
} 
 
 
 
/*
run:
 
6
 
*/

 



answered May 6, 2019 by avibootz

Related questions

1 answer 90 views
1 answer 102 views
102 views asked Apr 24, 2023 by avibootz
1 answer 150 views
2 answers 255 views
255 views asked May 8, 2019 by avibootz
2 answers 141 views
141 views asked Jan 21, 2022 by avibootz
1 answer 126 views
126 views asked May 11, 2021 by avibootz
1 answer 122 views
122 views asked May 11, 2021 by avibootz
...