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.

40,026 questions

51,982 answers

573 users

How to get size of struct in C

2 Answers

0 votes
#include <stdio.h>

enum { buffer_size = 32 };

struct buffer {
    size_t size;
    char bufferX[buffer_size];
};

int main(void) {
    printf("%zu", sizeof(struct buffer));
}




/*
compile:

40

*/

 



answered Apr 28, 2022 by avibootz
edited Apr 28, 2022 by avibootz
0 votes
#include <stdio.h>
 
#define SIZE 32
 
typedef struct {
    size_t size;
    char bufferX[SIZE];
} buffer;
 
int main(void) {
    printf("%zu", sizeof(buffer));
}
 
 
 
 
/*
compile:
 
40
 
*/

 



answered Jun 21, 2024 by avibootz

Related questions

1 answer 127 views
3 answers 148 views
1 answer 219 views
1 answer 117 views
1 answer 111 views
1 answer 101 views
101 views asked Jul 3, 2024 by avibootz
2 answers 100 views
...