试题7: void Test(void ){ char *str = (char *) malloc(100 ); strcpy(str, "hello" ); free
试题7:
void Test(void )
{
char *str = (char *) malloc(100 );
strcpy(str, "hello" );
free(str );
... //省略的其它语句
}
试题7:
void Test(void )
{
char *str = (char *) malloc(100 );
strcpy(str, "hello" );
free(str );
... //省略的其它语句
}
试题7:
void Test(void )
{
char *str = (char *) malloc(100 );
strcpy(str, "hello" );
free(str );
... //省略的其它语句
}
试题6:
void GetMemory(char **p, int num )
{
*p = (char *) malloc(num );
}
void Test(void )
{
char *str = NULL;
GetMemory(&str, 100 );
strcpy(str, "hello" );
printf(str );
试题5:
char *GetMemory(void )
{
char p[] = "hello world";
return p;
}
void Test(void )
{
char *str = NULL;
str = GetMemory();
printf(str );
}
试题6:
void GetMemory(char **p, int num )
{
*p = (char *) malloc(num );
}
void Test(void )
{
char *str = NULL;
GetMemory(&str, 100 );
strcpy(str, "hello" );
printf(str );
}
试题4:
void GetMemory(char *p )
{
p = (char *) malloc(100 );
}
void Test(void )
{
char *str = NULL;
GetMemory(str );
strcpy(str, "hello world" );
printf(str );
}
试题5:
char *GetMemory(void )
{
char p[] = "hello world";
return p;
}
void Test(void )
{
char *str = NULL;
str = GetMemory();
printf(str );
}
试题4:
void GetMemory(char *p )
{
p = (char *) malloc(100 );
}
void Test(void )
{
char *str = NULL;
GetMemory(str );
strcpy(str, "hello world" );
printf(str );
}
试题7:编写类String的构造函数、析构函数和赋值函数,已知类String的原型为:
class String
{
public:
String(const char *str = NULL); // 普通构造函数
String(const String &other); // 拷贝构造函数
~ String(void); // 析构函数
String & perate =(const String &other); // 赋值函数
private:
char *m_data; // 用于保存字符串
};
试题7:编写类String 的构造函数、析构函数
和赋值函数,已知类String的原型为:
class String
{
public:
String(const char *str = NULL); // 普通构造函
数
String(const String &other); // 拷贝构造函数
~ String(void); // 析构函数
String & perate =(const String &other); // 赋值
函数
private:
char *m_data; // 用于保存字符串
};