에서이 오류를 얻고있다 이유 :나는이 간단한 코드가 C의 ++ 코드
std::ifstream ifs;
ifs.open ("test.txt", std::ifstream::in);
char c = ifs.get();
while (ifs.good()) {
std::cout << c;
c = ifs.get();
}
ifs.close();
을하지만 오류를 많이는 무엇입니까?
Error 9 error C3083: 'ifstream': the symbol to the left of a '::' must be a type test.cpp
Error 8 error C2228: left of '.open' must have class/struct/union test.cpp
등등이 있습니다.
은 내가 콘솔 응용 프로그램에 VS2012를 사용하고
#include <iostream>
#include <fstream>
#include "stdafx.h"
using namespace std;
파일의 시작에서 이러한 정의가 있습니다.
EDIT1 : 미리 컴파일 된 헤더의
Warning 1 warning C4627: '#include <iostream>': skipped when looking for precompiled header use test.cpp
Warning 2 warning C4627: '#include <fstream>': skipped when looking for precompiled header use test.cpp
'std :: ifstream ifs;'의 직전에 코드를 게시 할 수 있습니까? 아마도 어딘가에 이전에 세미콜론을 놓친 것일 수 있습니다. –
std :: 포괄적으로 사용할 때 "using namespace std"줄을 버리십시오. – Bathsheba
[코드 작동 원리] (http://eval.in/31344). 함수에서 그 코드를 랩핑 했습니까? –