Linked Questions

67 votes
4 answers
289k views

Possible Duplicate: Why isn’t sizeof for a struct equal to the sum of sizeof of each member? Consider the following C code: #include <stdio.h> struct employee { int id; char ...
user avatar
16 votes
9 answers
13k views

When I run only the code fragment int *t; std::cout << sizeof(char) << std::endl; std::cout << sizeof(double) << std::endl; std::cout << sizeof(int) << std::...
user avatar
4 votes
9 answers
1k views

Possible Duplicate: Why isn’t sizeof for a struct equal to the sum of sizeof of each member? Why is the sizeof(); of this structure 16 bytes? I'm compiling in g++. struct bitmapfileheader {...
Lukas's user avatar
  • 51
6 votes
6 answers
13k views

Possible Duplicate: Why isn't sizeof for a struct equal to the sum of sizeof of each member? I was trying to understand the concept of bit fields. But I am not able to find why the size of the ...
user1367292's user avatar
  • 1,077
2 votes
5 answers
22k views

Possible Duplicate: Why isn't sizeof for a struct equal to the sum of sizeof of each member? Extra bytes when declaring a member of a struct as uint32_t For some reason, the sizeof operator ...
krb's user avatar
  • 16.4k
4 votes
2 answers
3k views

I already read this question: struct padding in c++ and this one Why isn't sizeof for a struct equal to the sum of sizeof of each member? and I know this isn't standardized but still I believe it'...
Dean's user avatar
  • 7,034
3 votes
2 answers
2k views

Possible Duplicate: Why isn't sizeof for a struct equal to the sum of sizeof of each member? #include <stdio.h> int main(){ struct word1{ char a; int b; char c; }; struct word2{ ...
Chankey Pathak's user avatar
4 votes
2 answers
1k views

Given example class class test { public: test(); ~test(); void someMethod(); void someOtherMethod(); private: int var; }; is sizeof(test) == sizeof(int), or we cannot make such assumption? Is it ...
Ilya Kobelevskiy's user avatar
0 votes
1 answer
7k views

To find the size of a structure in C struct student { char name; int age; float weight; }; main () { int i,j,k,l; struct student s1; i=sizeof(s1.name); j=sizeof(...
Sudheer's user avatar
  • 248
1 vote
6 answers
3k views

Okay really confused about something here. Two questions. First question is according to my compiler, string is always a size of 40 bytes. How is this possible when we can have more than 40 ...
user3503712's user avatar
4 votes
1 answer
5k views

I was trying to create a pair type using dynamic memory and then return it's address to the calling function, but on checking the size of the pair object I got confused: pair<int,vector<int> ...
Agrudge Amicus's user avatar
-2 votes
1 answer
3k views

So I am currently a student and am having a programming couse. Today we had about the use of sizeof in different classes(if it had 1 int or 2 int´s and so on) One part of the example I found weird ...
Sumsar1812's user avatar
-3 votes
3 answers
12k views

int main() { struct node { char i; int a; }; printf("sizeof(struct node) =%d\n",sizeof(struct node)); return 0; } The output for this program is 8 byte. Here sizeof(int)+size(char) ...
user3686233's user avatar
2 votes
5 answers
6k views

Possible Duplicate: Why isn’t sizeof for a struct equal to the sum of sizeof of each member? When you create a struct in C, for example: typedef struct student { int roll_no; char* name; int* ...
adijo's user avatar
  • 21
3 votes
5 answers
383 views

When I run following, it gives me output as 20. but int is of 4 byte,float is of 4 byte and character array is of 10 byte, then the total is 18 byte. Why I am getting output as 20 byte? #include<...
Amrut Dange's user avatar

15 30 50 per page
1
2 3 4 5
24