private:
// data containing character strings
// shared by Strings when copying/assigning
struct SharedData
{
char *data; // 0-terminated char array
size_t n; // number of non-0 characters in string
size_t count; // reference count, how many Strings share this object?
};
SharedData *shared; //here i don't understand how to use.
我如何使用 n?
我只是这样做吗
shared -> n = 3;
我不断收到分段错误,所以我不知道我在做什么。我想获取字符串的长度,然后将其传递给 n 进行存储