1 #ifdef 标识符 2 /*程序段 1*/ 3 #else 4 /*程序段 2*/ 5 #endif 6 7 它的作用是当标识符已经由#define定义过了,则编译程序段1,否则编译程序段2,也可以使用简单形式 8 9 #ifdef 标识符 10 /*程序段1*/ 11 #endif
1 enum Color 2 { 3 RED = 0, 4 BLACK = 1 5 }; 6 7 struct RBTreeNode 8 { 9 struct RBTreeNode*left, *right, *parent; 10 int key; 11 int data; 12 Color color; 13 };
#include<iostream> #include<string> using namespace std; char * fun() { char s[]="abc";//局部变量存储在栈中 return s;//返回的是栈指针 } string fun1(){ string s="abc"; return s; } int main(){ char *ptr=fun();//返回的栈指针,但是不管指向地方的内容是什么,一旦发生了函数调用(这里发生了函数调用,函数的入栈 //压栈操作使得上次栈指针往下压了(栈是向下生长的),指向的内容也就发生了变化
但是栈指针指向的所以返回的栈指针指向的内容就变了,返回乱码。 string s=fun1(); cout<<ptr<<endl; cout<<s<<endl; return 0; }
char *strcpy(char *strDest, const char *strSrc); { assert((strDest!=NULL) && (strSrc !=NULL)); // 2分 char *address = strDest; // 2分 while( (*strDest++ = * strSrc++) != ‘\0’ ) ;// 2分return address ; // 2分 }
原文:http://www.cnblogs.com/Kobe10/p/5790154.html