XCode C 中的字符串到char*

String to char* in Xcode c++

本文关键字:char 字符串 XCode      更新时间:2023-10-16

我像这样写代码

class A{
// ...
public:
insert(int key, char* contents){ ... }
}

想要使用

A.insert(1, "hellow world");

,但不允许从字符串字面转换为char*

如何使用这种方式?

字符串文字为 const char*

class A{
    // ...
    public:
    insert(int key, const char* contents){ ... }
}
// ...
A.insert(1, "hello world");