The character string mode specifies the type of access requested for the file, as follows:
"r"
Opens for reading. If the file does not exist or cannot be found, the fopen call fails.
"w"
Opens an empty file for writing. If the given file exists, its contents are destroyed.
"a"
Opens for writing at the end of the file (appending) without removing the EOF marker before writing new data to the file; creates the file first if it doesn't exist.
"r+"
Opens for both reading and writing. (The file must exist.)
"w+"
Opens an empty file for both reading and writing. If the given file exists, its contents are destroyed.
"a+"
Opens for reading and appending; the appending operation includes the removal of the EOF marker before new data is written to the file and the EOF marker is restored after writing is complete; creates the file first if it doesn't exist.
MSDN 에 있는
MSDN 에 있는 내용입니다.
"r" 이나 "r+" 는 파일을 생성하지는 않습니다.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_fopen.2c_._wfopen.asp
The character string mode specifies the type of access requested for the file, as follows:
"r"
Opens for reading. If the file does not exist or cannot be found, the fopen call fails.
"w"
Opens an empty file for writing. If the given file exists, its contents are destroyed.
"a"
Opens for writing at the end of the file (appending) without removing the EOF marker before writing new data to the file; creates the file first if it doesn't exist.
"r+"
Opens for both reading and writing. (The file must exist.)
"w+"
Opens an empty file for both reading and writing. If the given file exists, its contents are destroyed.
"a+"
Opens for reading and appending; the appending operation includes the removal of the EOF marker before new data is written to the file and the EOF marker is restored after writing is complete; creates the file first if it doesn't exist.
--
cdecl
아 그렇지만..
명쾌한 답변을 주시긴 했지만
생각해 보니까 MSDN이 C언어의 표준은 아니지 않습니까?
가끔 MS VC++와 gcc가 다른 결과를 내기도 하던데
gcc가 표준이라고 생각하는데
물고늘어지는 것 같아 죄송합니다...
ISO C 표준에 따라,
ISO C 표준에 따라, "r+"를 썼다면 fopen(3)은 파일이 없을 경우, 새로 만들지 않습니다.. 따라서 새로 만드는 C library가 있다면, 표준에 부합하는 라이브러리가 아닙니다.
--
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Korean Ver: http://www.cinsk.org/cfaqs/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Korean Ver: http://cinsk.github.io/cfaqs/
네 알겠습니다^^ 감사합니다
두분 모두 제가 원하는 답변을 주셨습니다.
두분 모두에게 진심으로 감사드립니다.
댓글 달기