c++ 코딩 파일 입력이 안됨..도와주세요ㅠㅠ
-
게시물 수정 , 삭제는 로그인 필요
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ifstream fin("test.txt"); // fin 객체 생성(cin 처럼 이용!)
if (!fin)
{
cout << "Error, no such file exists" << endl;
exit(100);
} // 파일 열림 확인
int i;
while (true)
{
fin >> i;
if (fin.eof()) // 읽어올 파일의 끝이면(End Of File)
{
break; // 읽기를 마치고 반복문을 나간다.
}
cout << i << endl;
}
fin.close(); // 파일 닫기
return 0;
}
로 하고 메모장에는
this
is
test
.
라고 적고 test로 저장했습니다.
그런데 계속 Error, no such file exists만 나오고 입력이 안되네요ㅠ
어디가 문제일까요?
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ifstream fin("test.txt"); // fin 객체 생성(cin 처럼 이용!)
if (!fin)
{
cout << "Error, no such file exists" << endl;
exit(100);
} // 파일 열림 확인
int i;
while (true)
{
fin >> i;
if (fin.eof()) // 읽어올 파일의 끝이면(End Of File)
{
break; // 읽기를 마치고 반복문을 나간다.
}
cout << i << endl;
}
fin.close(); // 파일 닫기
return 0;
}
로 하고 메모장에는
this
is
test
.
라고 적고 test로 저장했습니다.
그런데 계속 Error, no such file exists만 나오고 입력이 안되네요ㅠ
어디가 문제일까요?
#c++ 코딩테스트 #c++ 코딩 #c++ 코딩도장 #c++ 코딩 사이트 #c++ 코딩테스트 책 #c++ 코딩테스트 문법 #c++ 코딩 스타일 #c++ 코딩테스트 예제 #c++ 코딩테스트 책 추천 #c++ 코딩테스트 준비