#include <iostream> // 输入输出流的头文件
#include <string>
using namespace std;
int main()
{
char* psz = "asdasdasd"; //字符串类型
char sz[10] = "asdasdasd"; //字符数组
//----------------------------------------------------------
char* pszStr = new char[10];
strcpy_s(pszStr,10,"asdasdasd"); // 字符串的赋值不能用=, strcpy_s字符串的赋值操作
cout << pszStr;
delete[] pszStr;
pszStr = 0;
char sz[10] = {0};
strcpy_s(sz,10,"asdasdasd");
cout << sz;
//---------------------------string-------------------------------------------
//只有string 可以使用 + = == ,char的数组只能调用
string str = "aaaa";
cout << str << endl;
str = "bbbb";
cout << str << endl;
str = "ccccccc";
cout << str << endl;
string str1;
str1 = str+"kkkk";
cout << str1 << endl; //尾部添加
cout << (str1 == str) << endl;
cout << str[1] << endl;
system("pause");
return 0;
}
string
最新推荐文章于 2024-10-28 22:32:17 发布