Access violation reading location

This is a discussion on Access violation reading location within the C Programming forums, part of the General Programming Boards category; I can't find anything wrong with my code. When i debug, this occurs. Unhandled exception at 0x00fb74b1 in pacman.exe: 0xC0000005: ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    70

    Access violation reading location

    I can't find anything wrong with my code. When i debug, this occurs.

    Unhandled exception at 0x00fb74b1 in pacman.exe: 0xC0000005: Access violation reading location 0xfdfdfdfd.

    Code:
    printf("Lowest F = %d, x:%d, y:%d", lowestf, openX[lowestf], openY[lowestf]);
    	
    ScanAdjacentNodes(openX[lowestf], openX[lowestf]);
    The printf works fine, some integers are printed.

    If i parse values like this there is no problem.
    Code:
    ScanAdjacentNodes(5, 5);
    Code:
    int openX[550];
    int openY[550];
    Code:
    void ScanAdjacentNodes(int x, int y) {
    
    	if(FREE(x+1, y)) {
    		f[index]=hscore(x+1, y);
    		openX[index]=x+1;
    		openY[index]=y;
    		index++;
    	} else {
    		closedX[j] = x+1;
    		closedY[j] = y;
    		j++;
    	}
    	if(FREE(x-1, y)) {
    		f[index]=hscore(x-1, y);
    		openX[index]=x-1;
    		openY[index]=y;
    		index++;
    	} else {
    		closedX[j] = x-1;
    		closedY[j] = y;
    		j++;
    	}
    	if(FREE(x, y+1)) {
    		f[index]=hscore(x, y+1);
    		openX[index]=x;
    		openY[index]=y+1;
    		index++;
    	} else {
    		closedX[j] = x;
    		closedY[j] = y+1;
    		j++;
    	}
    	if(FREE(x, y-1)) {
    		f[index]=hscore(x, y-1);
    		openX[index]=x;
    		openY[index]=y-1;
    		index++;
    	} else {
    		closedX[j] = x;
    		closedY[j] = y-1;
    		j++;
    	}
    
    }
    Last edited by erasm; 08-24-2010 at 02:20 AM.

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    What's the signature for ScanAdjacentNodes()? And the definition of the variables? You haven't given enough information.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,172
    IIRC, 0xfdfdfdfd means that you're trying to use a freed variable.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 09-22-2009, 03:55 AM
  2. C - access violation
    By uber in forum C Programming
    Replies: 2
    Last Post: 07-08-2009, 01:30 PM
  3. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  4. Access violation when reading [00000000]?
    By phal in forum Windows Programming
    Replies: 12
    Last Post: 08-19-2008, 06:03 AM
  5. Access violation when reading a string.
    By Desolation in forum C++ Programming
    Replies: 16
    Last Post: 05-01-2007, 10:25 AM

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