C++ 프로그래밍을 공부하던 중, 예제 프로그램을 컴파일하다 다음과 같은 에러를 발견했다.

 Description    Resource    Path    Location    Type
‘nocreat’ is not a member of ‘std::ios’    Config.cpp    /TEMS/src    line 40    C/C++ Problem

 환경은 이클립스 3.5.2 버전이었으며, g++ 버전은 version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 이었다.

 문제의 원인을 찾기 위해 구글링을 해보니 답은 간단했다.

 더이상 ios::nocreate 는 표준 C++ 에서 지원하지 않는다는 것.

http://cboard.cprogramming.com/cplusplus-programming/48548-if-ofstream.html 에서 다음과 같은 답변을 찾았다.

 ios::nocreate was removed from standard c++, you may use ios::in to open
the file for reading, and not create one if it doesn’t exist.
The file shouldn’t be created if you have a standard compliant compiler.
(I think dc++ is)

ios::nocreate 를 쓰고 싶다면 그냥 ios::in 만 사용하면 된다. 🙂

Tags: ,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.