fopen当指定模式”w”时,如果文件不存在则创建一个空文件;如果文件已经存在,则会丢弃其原来的文件内容,将该文件作为一个新的空文件来写。The new C standard (C2011, which is not part of C++) adds a new standard subspecifier ("x"), that can be appended to any "w" specifier (to form "wx", "wbx", "w+x" or "w+bx"/"wb+x"). This subspecifier forces the function to fail if the file exists, instead of overwriting it.
展开
评论