con.txt和C ++ [英] con.txt and C++
问题描述
#include <fstream>
int _tmain(int argc, _TCHAR* argv[])
{
std::ofstream F("con.txt", std::ios::out);
F << "some text in con.txt";
F.close();
return 0;
}
输出:
some text in con.txt
code> something.txt ,则something.txt将包含字符串一些文本在something.txt
。
If i replace "con.txt
" with "something.txt
" then something.txt will contains the string "some text in something.txt
."
我认为文件con.txt绑定一个控制台文件...什么是真实的在第一种情况下?
I think that the file con.txt bind with a console file... What is real happened in the first case?
推荐答案
CON
是保留设备名称在Windows平台上。
CON
is a reserved device name on Windows platforms. It shouldn't be used as a file name, even with an extension.
在文档:
以下为文件名保留
设备名:
CON
,PRN
AUX
,NUL
,COM1
,COM2
,COM3
,
COM4
,COM5
,COM6
,COM7
,COM8
,COM9
,
LPT1
,LPT2
,LPT3
,LPT4
,LPT5
,LPT6
,
LPT7
,LPT8
c $ c> LPT9 。也避免这些
名称后面紧跟一个
扩展名;例如NUL.txt
不是推荐的
。
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
, andLPT9
. Also avoid these names followed immediately by an extension; for example,NUL.txt
is not recommended.
这篇关于con.txt和C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!