我正在尝试更多地了解 C++ 字符串。
考虑
const char* cstring = "hello";
std::string string(cstring);
和
std::string string("hello");
我是否正确假设两者都在应用程序的 .data 部分存储“hello”,然后将字节复制到堆上的另一个区域,由 std::string 管理的指针可以访问它们?
我怎样才能有效地存储一个非常长的字符串?我有点想从套接字流中读取数据的应用程序。我害怕连接很多次。我可以想象使用一个链表并遍历这个列表。
弦乐吓唬我太久了!
任何链接、提示、解释、更多细节都会非常有帮助。