Debug Assertion Failed!

This is a discussion on Debug Assertion Failed! within the C++ Programming forums, part of the General Programming Boards category; I've got a program that works fine while i'm in the VC program, however, when I try to launch the ...

  1. #1
    Registered User Ray Schmidt's Avatar
    Join Date
    Feb 2003
    Posts
    17

    Question Debug Assertion Failed!

    I've got a program that works fine while i'm in the VC program, however, when I try to launch the .exe stand alone I get this nasty little message:

    Debug Assertion Failed!
    Program: C:\My.....
    File: fseek.c
    Line: 101
    Expression: stream != NULL

    I'm sure i'm just missing it. Maybe someone can suggest a better way to get i/p from a text file... Any help is appreciated...
    Code:
    void CPeekaViewDlg::OnGetit() 
    {
    	UpdateData(TRUE);
    	
    	FILE *stream;
    	char s[255];
    	int i=74;
    	int convert;
    	stream=fopen("t2.tre","r");
    	fseek(stream, i, SEEK_SET);
    	fscanf(stream,"%s\n",s);
    	m_crap = s;
    	convert = atoi(s);
    	if(convert>9)
    	{
    		i += 3;
    	}
    	if(convert<9)
    	{
    		i += 2;
    	}
    	fseek(stream, i, SEEK_SET);
    	fscanf(stream,"%s\n",s);
    	m_show = s;
    
    
    	fclose(stream);
    
    	UpdateData(FALSE);
    
    }

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    311
    my guess, t2.tre does not exist in the same directory. errno will be nonzero if fopen fails and strerr(errno) will proablably have a semi informative message.

  3. #3
    Registered User Ray Schmidt's Avatar
    Join Date
    Feb 2003
    Posts
    17

    it exist

    The file is present and has data. In fact, the code actually works, but only while the program is compiled/linked/ran from the VC++ program....

  4. #4
    Registered User Ray Schmidt's Avatar
    Join Date
    Feb 2003
    Posts
    17

    Lightbulb I've got it!!!! WoooHooo!!!

    It truns out that a full path is needed.

    stream=fopen("c:/mydocu~1/programming/peekaview/t2.tre","r");


    Thanks...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debug Assertion Failed!
    By IndioDoido in forum C Programming
    Replies: 31
    Last Post: 03-25-2008, 11:07 AM
  2. debug assertion failed!
    By chintugavali in forum C++ Programming
    Replies: 5
    Last Post: 12-21-2007, 03:05 AM
  3. Visual Studio 2005 Debug Assertion Failed
    By natmas in forum C++ Programming
    Replies: 7
    Last Post: 07-17-2007, 04:28 PM
  4. debug assertion failed !
    By blue_gene in forum C++ Programming
    Replies: 2
    Last Post: 05-09-2004, 11:23 AM
  5. debug assertion failed?!?
    By ichijoji in forum C++ Programming
    Replies: 3
    Last Post: 08-30-2003, 03:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21