主题:疑惑!!!!
shudou
[专家分:0] 发布于 2008-03-16 09:20:00
请教各位 get 和 getline 的具体用法 和区别
回复列表 (共1个回复)
沙发
f-wind [专家分:1240] 发布于 2008-03-17 11:53:00
Gets a line from the input stream.
basic_istream& getline(
char_type *_Str,
streamsize _Count
);
basic_istream& getline(
char_type *_Str,
streamsize _Count,
char_type _Delim
);
Parameters
_Count
The number of characters to read from strbuf.
_Delim
The character that should terminate the read if it is encountered before _Count.
_Str
A string in which to write.
Return Value
The stream (*this).
// basic_istream_getline.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;
int main( )
{
char c[10];
cin.getline( &c[0], 5, '2' );
cout << c << endl;
}
Input
12
Output
1
我来回复