Advertisement

Understanding an error in C++

Started by June 26, 2003 04:21 AM
7 comments, last by Henszey 21 years, 8 months ago
I have been programing with OpenGL in Visual Basic for awhile i decided that i might try C++, i played around with generel C++ for about a month and am now trying to use OpenGL. I am getting an error "Debug Assertion Failed!" File: Fgets.c Line: 60 Expression: str != NULL and gives me an Abort, Retry, Ignore box, when i hit retry it gives me the option to debug it, but that really doesnt help, What i am trying to do is read in a .obj file and make a list from it. if some one can help me figure out what this means or get me headed down the right path that would help.
Well i fixed my problem, through one way. If i run the exe file on my own it runs fine, but if i run it from inside Visual C++ it gives me the error, why is that?
Advertisement
Post the code. You screwed up somewhere. Obviously debug error output is not included in the release executable, but the error is still there.

[edited by - haro on June 26, 2003 5:35:33 AM]
Some general info about this here.
-solo (my site)
Debug Assertions are ways for you to catch errors when running in debug mode. Sometimes they are critical, sometimes just of interest. Since the assertion is in fgets.c, it has to do with your use of fgets or a related function. Try to track down where you use it, and make sure you''re using it right. The line "Expression: str != NULL" means that the code is checking if str!= NULL, but it turns out that str is equal to null, so it alerts you that something is wrong.

do
{
fgets(string, 255, f);
} while ((string[0] == ''/'') || (string[0] == ''\n''


This is the code that i believe i s causing the error, it makes it sound like its getting nothing out of the file but i know it is
Advertisement
Haha.. the file pointer is invalid. Make sure the file exists mate. After you open the file, make sure its not equal to NULL. For example:

FILE* fp = fopen("c:/sex.txt", "r");
if( fp == NULL )
return 1;




[edited by - haro on June 26, 2003 2:04:30 PM]
bléh.. c:\sex.txt.. hm.. Do I have that too?

.lick
Heh i got it, i had my file in /debug/data/ship.obj because thats where i thought it would be executed from since the exe is in there, when i moved it to just /data/ship.obj it worked fine, thats why i could run it from the exe in the /debug folder, thatnks for your help, telling me that the file didnt exist let me figure it out

This topic is closed to new replies.

Advertisement