#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <ctime>
#include <vector>
using namespace std;
#if 1
struct Student {
char sName[255];
int iHeight;
float fWeight;
};
int main(void) {
Student a1;
strcpy_s(a1.sName, "Tom Henry");
a1.iHeight = 175;
a1.fWeight = 120.2;
cout << "sizeof(a1):" << sizeof(a1) << endl;
cout << a1.sName << endl;
}
#endif
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <ctime>
#include <vector>
using namespace std;
#if 1
union Dummy {
char c;
int i;
float f;
};
int main(void) {
Dummy a;
cout << "addr of a.c:" << (int)&a.c << endl;
cout << "addr of a.i:" << (int)&a.i << endl;
cout << "addr of a.f:" << (int)&a.f << endl;
cout << "sizeof dummy:" << sizeof(Dummy) << endl;
cout << "sizeof a:" << sizeof(a) << endl;
a.c = '0';
a.i = 1000;
a.f = 999.99;
cout << "a.c:" << a.c << "a.i:" << a.i << "a.f:" << a.f << endl;
return 0;
}
#endif