Preview:
#include <iostream>
using namespace std;
struct StructName{
    int a;
    float b;
    char c;
};
union UnionName{
    int a;
    float b;
    char c;
};
int main()
{
	cout << "嗨客网(www.haicoder.net)\n" << endl;
	int sizeStruct = sizeof(struct StructName);
    int sizeUnion = sizeof(union UnionName);
    cout << "sizeStruct = " << sizeStruct << " sizeUnion = " << sizeUnion << endl;
	return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter