COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
struct_size.cpp
Go to the documentation of this file.
1#include <iostream>
2using namespace std;
3
4// Different order of data members in the struct
5// would result in different size of the struct
6struct structA{
7 char c; double d; int i;
8};
9
10struct structB{
11 double d; int s; char c;
12};
13
14
15int main(){
16 cout << sizeof(struct structA) << " " << sizeof(struct structB) << endl;
17}
int main()
double d
double d