cin.getline(_Elem *_Str, streamsize _Count);
cin.getline(_Elem *_Str, streamsize _Count, _Elem _Delim);
使用cin.getline()
时,可以传递2个参数,即:存储地址*_Str
和读入的数量_Count
。在这种情况下如果输入的内容大于_Count
,则在最后自动添加结束标志,这样的话,实际读进来的数量是_Count-1
;也可以传递3个参数,自己指定结束标志。
cin.getline(_Elem *_Str, streamsize _Count);
cin.getline(_Elem *_Str, streamsize _Count, _Elem _Delim);
使用cin.getline()
时,可以传递2个参数,即:存储地址*_Str
和读入的数量_Count
。在这种情况下如果输入的内容大于_Count
,则在最后自动添加结束标志,这样的话,实际读进来的数量是_Count-1
;也可以传递3个参数,自己指定结束标志。