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>
2
using namespace
std;
3
4
// Different order of data members in the struct
5
// would result in different size of the struct
6
struct
structA
{
7
char
c
;
double
d
;
int
i
;
8
};
9
10
struct
structB
{
11
double
d
;
int
s
;
char
c
;
12
};
13
14
15
int
main
(){
16
cout <<
sizeof
(
struct
structA
) <<
" "
<< sizeof(struct
structB
) << endl;
17
}
main
int main()
Definition
struct_size.cpp:15
structA
Definition
struct_size.cpp:6
structA::i
int i
Definition
struct_size.cpp:7
structA::c
char c
Definition
struct_size.cpp:7
structA::d
double d
Definition
struct_size.cpp:7
structB
Definition
struct_size.cpp:10
structB::c
char c
Definition
struct_size.cpp:11
structB::s
int s
Definition
struct_size.cpp:11
structB::d
double d
Definition
struct_size.cpp:11
Module7
struct_size.cpp
Generated on Sun Sep 29 2024 16:39:53 for COMP2113 by
1.12.0