Why does fstream.open() fail “If the mode has both trunc and app set”?

蓝咒 提交于 2019-12-06 05:51:24

The iostream open modes correspond roughly to the fopen mode in the C library and fopen has a w mode that truncates and an a mode that appends, but no combination of the two.

The allowable combinations of flags are specified in [filebuf.members] in the standard. Table 132 gives the possibilities:

So, since the combination of trunc and app isn't in the table, the open is required to fail.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!