我们如何区分 C++ 中的字符数组和字符串?有什么 char 数组比 std::string 做得更好的吗?
我正在尝试初始化 main() 中的数组。但我收到一个错误。这是代码的样子:
#include<iostream>
#include<string.h>
using namespace std;
class word
{
public:
char str[20];
};
int main()
{
word a;
word b;
a.str[]="12345";
b.str[]="67";
}
Run Code Online (Sandbox Code Playgroud)
'a' 和 'b' 是类词的 2 个对象。