数据地址和指针的思考
void main()
{
int a[3] = { 1,2,3 };
// PrintArray(&a[0]);
// PrintArray(a);
cout << (int)a << endl;
cout << (int)(a +1) << endl;
cout << (int)&a << endl;
cout << (int)(&a + 1) << endl;
getchar();
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
using namespace std;
typedef struct _em
{
char name[10] ;
int age = 29;
}Employee;
void main()
{
Employee employee;
strcpy(employee.name, "Michael");
employee.age = 29;
cout << sizeof(Employee) << endl;
char* ptr = employee.name;
cout << "name = " << sizeof(ptr) << endl;
int* pint = &employee.age;
ptr += sizeof(employee.name);
cout << sizeof(&employee.name) << endl;
cout << sizeof(employee.name) << endl;
cout << "age = " << (int)ptr << endl;
cout << "age = " << (int)pint << endl;
cout << "hello poem" << endl;
system("pause");
}
结构体内存对齐以4字节为倍数。