getline处显示错误
#include<iostream>
#include<sstream>
#include<string>
using namespace std;
int main(int argc, char*argv[])
{
string strText = "How are you?";//源串
string strResult = "";
stringstream istr(strText);
while (!istr.eof())
{
getline(strText, strResult, ',');//读入输入流并给变量赋值
cout << "string=" << strResult << endl;
}
return 0;
}
#include<sstream>
#include<string>
using namespace std;
int main(int argc, char*argv[])
{
string strText = "How are you?";//源串
string strResult = "";
stringstream istr(strText);
while (!istr.eof())
{
getline(strText, strResult, ',');//读入输入流并给变量赋值
cout << "string=" << strResult << endl;
}
return 0;
}
...全文
相关推荐
09-10-2电类上机考试试卷_B.doc
09-10-2电类上机考试试卷_B.doc
福彩C++代码
有关于C++课程设计当中的,有关于福彩的代码
C++中getline()的用法详解
getline()用法 getline是C++标准库函数;它有两种形式,一种是头文件中输入流成员函数;一种在头文件中普通函数; 它遇到以下情况发生会导致生成的本字符串结束: (1)到文件结束,(2)遇到函数的定界符,(3)输入达到最大限度。 输入流成员函数getline() 函数语法结构: 在中的getline()函数有两种重载形式: istream& getline (char* s, streamsize n ); istream& getline (char* s, streamsize n, char delim )
使用ifstream和getline读取文件内容[c++]
c++、getline、每次读取一行txt; //读取方式: 逐词读取, 词之间用空格区分; //读取方式: 逐行读取, 将行读入字符数组, 行之间用回车换行区分; //读取方式: 逐行读取, 将行读入字符串, 行之间用回车换行区分
c++中的两种getline用法详解
c++中有2种getline函数,一种在头文件 中,是istream类的成员函数;另一种是在头文件 中,是普通函数。这篇文章主要介绍了c++中的两种getline用法,需要的朋友可以参考下


新手乐园
