C++中getline(cin,string)最多一行能读取多少个字符

[复制链接]
查看11 | 回复1 | 2016-11-10 03:16:41 | 显示全部楼层 |阅读模式
如果getline(cin,string)不能读取100个以上的字符串,那什么可以

回复

使用道具 举报

千问 | 2016-11-10 03:16:41 | 显示全部楼层
这个不是固定的长度,刚开始会初始化一个长度,但是当行超出这个长度的时候,getline会重新给这个buffer长度进行开辟,来适应变长的行。请参看考我给出来链接中的英文说明部分。“
If *lineptr is NULL, the getline() routine will allocate a buffer for containing the line, which must be freed by the user program. Alternatively, before calling getline(), *lineptr can contain a pointer to a malloc()-allocated buff
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行