07 2013 档案

MS VC 自然对齐 声明示例
摘要:#include using namespace std;typedef unsigned char BYTE;enum Color {RED = 0x01,BLUE,GREEN,YELLOW,BLACK};#ifdef _MSC_VER#pragma pack(push,8)#endifstruct Sedan{ double m_price; Color m_color; bool m_hasSkylight; bool m_isAutoShift; BYTE m_seatNum;};#ifdef _MSC_VER#pragma pack(pop);#endif 阅读全文

posted @ 2013-07-23 11:14 Yours风之恋 阅读(160) 评论(0) 推荐(0)

C++ 中内存分配和回收
摘要:void Allocate(char* &p,int size) { p = (char*)malloc(size);}void Test(void) { char *str = NULL; Allocate(str,100); strcpy(str,"Hello World!"); printf(str); free(str);} 阅读全文

posted @ 2013-07-16 09:51 Yours风之恋 阅读(224) 评论(0) 推荐(0)