con.txt and C++

后端 未结 1 1150
名媛妹妹
名媛妹妹 2020-12-16 17:31
#include 

int _tmain(int argc, _TCHAR* argv[])
{
   std::ofstream F(\"con.txt\", std::ios::out);

   F << \"some text in con.txt\";

   F.close         


        
相关标签:
1条回答
  • 2020-12-16 18:02

    CON is a reserved device name on Windows platforms. It shouldn't be used as a file name, even with an extension.

    From the documentation:

    Do not use the following reserved device names for the name of a file: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended.

    0 讨论(0)
提交回复
热议问题