Assertion Failure

This is a discussion on Assertion Failure within the Windows Programming forums, part of the Platform Specific Boards category; Noone has posted revised code for fopen....

  1. #16
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    ..

    Noone has posted revised code for fopen.

  2. #17
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    ...

    all new source code...
    Attached Files Attached Files

  3. #18
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231

    Re: ..

    Originally posted by drdroid
    Noone has posted revised code for fopen.
    You should read all the posts thoroughly, in particular the one by Unregistere21.
    Code:
    if ((filein = fopen("World.txt", "rt")) == NULL)
    	{
    		MessageBox(NULL, TEXT("Failure"), TEXT("Test:"), 0);	
    	}
    You must do better error handling, there's no point in continuing the program if the file open fails.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #19
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    ..

    that checks to see if the variable opens the file. That is not a fix that is a check. I already used that.

  5. #20
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    OK, look at evidence so far:

    I said:
    >>Use this snippet: sprintf(buffer, "%p %p", string, f); in the readstr() function to trap the values of the two key pointers.

    You responded with:
    >>The buffer messagebox comes up as 0066FA6C 00000000

    Therefore, the value of f is NULL. f is a FILE*, which is populated by this:
    >filein = fopen("World.txt", "rt")

    Therefore, we can assume that the fopen() is returning NULL, meaning that the file open failed, and the filein variable is not usable.

    So now you say:
    >>that checks to see if the variable opens the file. That is not a fix that is a check. I already used that.
    Huh? What I suggested wasn't supposed to fix the open, only highlight the problem and stop you from using a FILE* that is broken.
    Does this message box pop up:
    Code:
    if ((filein = fopen("World.txt", "rt")) == NULL)
    	{
    		MessageBox(NULL, TEXT("Failure"), TEXT("Test:"), 0);	
    	}
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #21
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    ..

    yes that message pops up.

  7. #22
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231

    Re: ..

    Originally posted by drdroid
    yes that message pops up.
    Hurray, we're finally getting somewhere.

    Are you sure :
    1 - World.txt exists.
    2 - it's in the correct directory (ie the programs working directory).
    3 - you have read permission to it

    #2 is the most likely cause of the problem, imho.

    Anyway, I can't help you any further, we've found your problem. Once you find out why you cannot access World.txt, and fix that, you'll be away again.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  8. #23
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    thanks..

    I couldn't believe it, I thought I had tested the file in both spots. Well, something so obvious; again, typical of me. Thank you so much.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File I/O Assertion Failure in VS2008
    By clegs in forum C Programming
    Replies: 5
    Last Post: 12-25-2008, 03:47 AM
  2. Debug Assertion failure problem
    By uldaman in forum C++ Programming
    Replies: 8
    Last Post: 01-21-2008, 01:22 AM
  3. debug assertion failure
    By talz13 in forum Windows Programming
    Replies: 2
    Last Post: 07-20-2004, 11:23 AM
  4. Assertion failure while creating window
    By roktsyntst in forum Windows Programming
    Replies: 0
    Last Post: 02-10-2003, 07:18 PM
  5. Assertion Failure
    By drdroid in forum Game Programming
    Replies: 9
    Last Post: 01-04-2003, 06:02 PM

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