C++中如何将两个连续的string 类型存入到文件中并读取出来?

日期:2016-04-24 03:15:25 人气:2

C++中如何将两个连续的string 类型存入到文件中并读取出来?

这里假设string类型可能包含任意字符。否则,只需用不可能出现的字符分隔开即可。 因此,唯一的办法是将string的长度也写入到文件当中。下面是示例: #include #include #include #include #include inline void WriteString(std::ostream& ostr, std::string const& str) { // 写入字符串长度 ostr > size; // 读取字符串
    A+
热门评论