gpt4 book ai didi

c++ - ungetc 有 C++ 版本吗?

转载 作者:行者123 更新时间:2023-11-30 00:58:12 26 4
gpt4 key购买 nike

是否有 ungetc 的 C++ 版本?

也就是说,我可以将角色放回 istream 吗?

最佳答案

是的。 istream::putback与 ungetc except if using unget() 相同:

You can't lie with unget(). It "ungets" the last-read character. You can lie with putback(c). You can "putback" some character other than the last-read character. Sometimes putting back a character other than the last-read character can be useful.

Also, if the underlying read buffer really does have buffering capability, you can "putback" more than one character. I think ungetc() is limited to one character.

关于c++ - ungetc 有 C++ 版本吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6915054/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com