头文件中的 ifndef/define/endif 的作用
New delete 与malloc free 的联系与区别?
分别写出BOOL,int,float,指针类型的变量a 与“零”的比较语句。
以下代码有什么问题?cout (true?1:"1") endl;
以下代码能够编译通过吗,为什么?unsigned int const size1 = 2; char str1[ size1 ]; unsigned int temp = 0; cin temp; unsigned int const size2 = temp; char str2[ size2 ];
以下代码有什么问题? typedef vector IntArray; IntArray array; array.push_back( 1 ); array.push_back( 2 ); array.push_back( 2 ); array.push_back( 3 ); // 删除array数组中所有的2 for( IntArray::iterator itor=array.begin(); itor!=array.end(); ++itor ) { if( 2 == *itor ) array.erase( itor ); }
void GetMemory(char *p){p = (char *)malloc(100);}void Test(void){char *str = NULL;GetMemory(str);strcpy(str, "hello world");printf(str);}请问运行Test函数会有什么样的结果?
void GetMemory2(char **p, int num){*p = (char *)malloc(num);}void Test(void){char *str = NULL;GetMemory(str, 100);strcpy(str, "hello");printf(str);}请问运行Test函数会有什么样的结果?