普通读入
int main()
{
string line:
while(getline(cin,line))
cout<<line<<endl;
return 0;
}
从文件中读入
int main()
{
ifstream ifs("unicode_big_endian.txt");
string str;
int i = 0;
while(getline(ifs, str))
{
printf("%04X\n", *(unsigned short *)str.c_str());
}
return 0;
}
往往要在连续读入之前加个getline()吸收上次的换行符。
https://blog.csdn.net/best_fiends_zxh/article/details/53064771