编写strcat函数(6分) 已知strcat函数的原型是char *strcat (char *strDest, const char *st
编写strcat函数(6分) 已知strcat函数的原型是char *strcat (char *strDest, const char *strSrc); 其中strDest 是目的字符串,strSrc 是源字符串。 (1)不调用C++/C 的字符串库函数,请编写函数 strcat
编写strcat函数(6分) 已知strcat函数的原型是char *strcat (char *strDest, const char *strSrc); 其中strDest 是目的字符串,strSrc 是源字符串。 (1)不调用C++/C 的字符串库函数,请编写函数 strcat
试题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; // 用于保存字符串
};
回答下面的问题(6分) (1).Void GetMemory(char **p, int num) { *p = (char *)malloc(num); } void Test(void) { char *str = NULL; GetMemory(&str, 100); strcpy(str, "hello"); printf(str); } 请问运行Test 函数会有什么样的结果?
已知String类定义如下:
class String
{
public:
String(const char *str = NULL); // 通用构造函数
String(const String &another); // 拷贝构造函数
~ String(); // 析构函数
String & perater =(const String &rhs); // 赋值函数
private:
char *m_data; // 用于保存字符串
};
尝试写出类的成员函数实现。
已知strcpy 的函数原型:char *strcpy(char
*strDest, const char *strSrc)其中strDest 是目的字符
串,strSrc 是源字符串。不调用C++/C 的字符串库
函数,请编写函数strcpy。
编写一个能对任意mxn阶矩阵进行转置运算的函数Transpose() 。
ba-1)。试编写一个函数,将数组中两个顺序表的位置互换,即将(b0,b1,…,bn-1)放在(a0,a1,…,am-1)的前面。
. void Test(void) { char *str = (char *) malloc(100); strcpy(str, “hello”); free(str); if(str != NULL) { strcpy(str, “world”); printf(str); } } 请问运行Test 函数会有什么样的结果?