-
Assertion Failure
Ok, so I'm learning Lesson 10 on First Person Movement on Nehe.gamedev.net OpenGLTutorials. I copied the code and pasted it. I've put down all of the libraries and checked all of the file connections. I get this assertion failure. I'll copy the error message as I see it:
Code:
Debug Assertion Failed!
Program: E:\Programs\...\OpenGL Tests\Test 6\Test 6\Debug\Test 6.exe
File: fgets.c
Line: 60
Expression: str !=NULL
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
I hear there is a tool in MVC++ that I can use. What is it? If not, know of any other way to cure my program of this error? I have no idea...:confused:
-
Ok!
Alright, I found the debug program and I ran through it and it led to a line in the code that said
Code:
_ASSERTE(str != NULL);
edit: this code snipit is from fgets.c
What's wrong with it? What do I do about it?
-
You're passing a NULL pointer to a function expecting a string, as far as I can see... It happens with ifstream/fstream when you supply it with a NULL pointer as the filename argument.
Can we see the code?
-
code..
-
..
I think you may need a bmp file to go along with it. So I guess I'll include that along too. This one came with the lesson on nehe.
-
Modify your readstr() function to look like this:
Code:
void readstr(FILE *f,char *string)
{
if (string == NULL) { MessageBox(HWND_DESKTOP, "Ahem", "Error!", MB_OK|MB_ICONERROR); return; }
do
{
fgets(string, 255, f);
} while ((string[0] == '/') || (string[0] == '\n'));
return;
}
Then run your code and tell me if that Message comes up. Lets localize this problem, and since you said something about fgets, this seems like a likely culprit.
-
..
I still get teh error message.
-
..
-
..
Should I ask this on another board? Windows, C++?
-
Thanks for cross posting :rolleyes: Next time, PM a mod if you want your thread moved.