Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我这里有一些代码从文本文档中读取并将其存储到char bunz. 我知道这听起来像一个愚蠢的问题,但我宁愿使用string而不是 char。.getline如果与 ? 一起使用,将接受字符串ifstream?还是我会被迫将字符转换为字符串后缀?
char bunz
string
.getline
ifstream
谢谢。
ifstream filler("C:\\bunz.txt"); char bunz[30+1]; filler.getline(bunz, 40); cout<<bunz; filler.close();
克里斯因将答案作为评论发布而臭名昭著,他在. 一旦你使用std::getline(),你将永远不会回去:
std::getline()
ifstream filler("C:\\bunz.txt"); string bunz; getline(filler, bunz); cout<<bunz; filler.close();