Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6726323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:54:50+00:00 2026-05-26T09:54:50+00:00

I am getting Access violation error from the debugger, but I really have no

  • 0

I am getting Access violation error from the debugger, but I really have no idea why. I suspect that it would be something really stupid.
I have an array of directory entries:

typedef struct dirEntry{
    TCHAR fileName[MAX_PATH];
    DWORD fileSizeLow;
    DWORD fileSizeHigh;
} dirEntry;

DWORD bufferSize = MEM_SIZE; //MEM_SIZE = 100
DWORD bufferPosition = 0;
dirEntry* dirBuffer;

dirBuffer = (dirEntry*) malloc(bufferSize*sizeof(dirEntry));

Then I pass it to a function ListDirectory(_T("D:\\books\\*"), dirBuffer, &bufferSize, &bufferPosition)

Inside the function I retrieve information about the files inside, but when I call this:

dirBuffer[*bufferPosition].fileSizeLow = dataFound.nFileSizeLow;
_tcscpy(dirBuffer[*bufferPosition].fileName, dataFound.cFileName);
*bufferPosition++;

The first line produces an exception. Can somebody please tell me what I’m doing wrong?

EDIT: Code of ListDirectory as demanded: http://pastebin.com/ScbcqX7p

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:54:51+00:00Added an answer on May 26, 2026 at 9:54 am

    *bufferPosition++ does not do what you think it does. It dereferences bufferPosition, then increments the pointer, not the value pointed to. You probably wanted (*bufferPosition)++, which increments the pointed-to value.

    Mind you, it’s not clear why you are passing bufferPosition and bufferSize by address, since they are useless to the caller, since ListDirectory frees the data the variables refer to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a (to me) weird run-time access violation error. I have a class,
I am getting an error: Message: SQLSTATE[42000]: Syntax error or access violation: 1064 You
I am getting an access violation error in an unmanaged dll I am writing,
I have some programs that use MapViewOfFile to share data, but I am getting
Hi I am getting an access violation error..... What might be the problem in
I get an access violation error in release mode, but not debug mode. The
I am continuously getting an Access Violation Error with a all my kernels which
I'm getting an Access Violation in DBEXPSDA40.DLL (Dev Art MS SQL Server dbexpress driver)
I am getting an 'Access to the path is denied error message when running
I am getting an 'access is denied' error when I attempt to delete a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.