小编vet*_*ton的帖子

何时在 C++ 中使用字符数组而不是字符串?

我们如何区分 C++ 中的字符数组和字符串?有什么 char 数组比 std::string 做得更好的吗?

c++ stdstring string-literals

8
推荐指数
1
解决办法
240
查看次数

将字符串分配给结构的属性

我正在尝试初始化 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 个对象。

c++

1
推荐指数
1
解决办法
53
查看次数

标签 统计

c++ ×2

stdstring ×1

string-literals ×1