(1)istream& getline ( istream& is, string& str, char delim ); istream& getline ( istream& is, string& str );
Get line from stream
Example
#include<iostream>
#include<sstream>
using namespace std;
int main()
{
string str, line;
//string* test;
while(getline(cin, line))
{
istringstream stream(line);
while(stream>>str)
cout<<str<<endl;
}
return 0;
}
#include<sstream>
using namespace std;
int main()
{
string str, line;
//string* test;
while(getline(cin, line))
{
istringstream stream(line);
while(stream>>str)
cout<<str<<endl;
}
return 0;
}
(2)istream& getline (char* s, streamsize n ); istream& getline (char* s, streamsize n, char delim );
Get line from streamExample
|