[CG] 파일입출력 오류 / 해결

런타임 에러가 났다.

[오류 메시지 내용]
Debug Assertion Failed!
Program: ...<exe파일 경로>
File: <cpp파일경로>
Line: 32
Expression: stream != nullptr
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)

[작성하던 코드 일부]
FILE* fp;
fp = fopen("apple.obj", "r");
int count = 0;
char ch;
float x, y, z;

for (register int j = 0; j < 100000; j = j + 1) {
 count = fscanf(fp, "%c %f %f %f", &ch, &x, &y, &z);
 if (count == 4 && ch == 'v') {
  vertex[j].X = x / scale;
  vertex[j].Y = y / scale;
  vertex[j].Z = z / scale;
 }
}
fclose(fp);


1. stream != nullptr

이라는 것은 fp(포인터)가 null이라는 소리.
즉 파일이 제대로 열리지 않았다.

경로확인결과 놀랍게도 cpp가 들어있는 폴더의 상위폴더에 obj파일(열고자 하는 파일)을 넣어놨었다...ㅎㅅㅎ

실행된 모습

2. 그래도 해결되지 않았다면

1) 파일이 제대로 존재하는지 확인
2) 상대경로나 직접경로로 경로 수정

*참고한 곳
http://www.hackerschool.org/HS_Boards/zboard.php?id=QNA_programming&no=2547
http://prosto.tistory.com/90

댓글

이 블로그의 인기 게시물

[MFC] LNK2001 외부 기호를 확인할 수 없습니다.

[Darkflow] 두달간 사용하며 알게된 것들