1.读取字符串只能用提取操作符>>吗?有没有像单字符一样的成员函数?
2.已读取的字符串现在不想处理如何放回输入流中?
例如
input>>ss;//ss字符串
ss放回输入流;
input>>cc;//cc单字符
ss我现在不想处理,我想把它放回输入流,并读取一个单字符,cc的值应该是(假如ss是文件中间的文本,且前面没有空白符号)ss的第一个值。
不需要放回输入流阿,你已经读取了。用string a= "1234567";
然后 char b = a.at(0);不就好了吗。
#include <string>
#include <stdio.h>
using namespace std;
int main() {
/// <summary>
/// 你不想操作的数据
/// </summary>
/// <returns></returns>
string s = "123456";
printf("%c", s.at(0));
return 0;
}
c++ 除了istream,ostream,iostream,还有 sstream
具体您有什么不清楚的地方,都可以找我。
http://www.cplusplus.com/reference/sstream/stringstream/stringstream/
string类型的变量 比方说string a 可以直接用a. size来获取长度 或者用strlen函数
也许对你有帮助:https://blog.csdn.net/it_xiangqiang/category_10581430.html