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 9212149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:27:32+00:00 2026-06-18T01:27:32+00:00

With the code: int nsize; int * buffer; char TargetBuffer[4096]; const SIZE_T buffersize =

  • 0

With the code:

int nsize;
int * buffer;
char TargetBuffer[4096];
const SIZE_T buffersize = (320*240) * sizeof(int);


buffer = (int *) malloc(bufferSize);
// fill buffer with data

nsize = 0;
while(nsize < buffersize)
{
    // HERE after some loops i get Access Violation
    memcpy(TargetBuffer, buffer + nsize, 4096);


    // do stuff with TargetBuffer
    nsize += 4096;
}

Why am I get the Access Violation? What should I change?

  • 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-06-18T01:27:33+00:00Added an answer on June 18, 2026 at 1:27 am

    When you add buffer + nsize you have to realize that you are actually adding buffer + (nsize * (sizeof(int)) since it’s a int * when you are doing pointer arithmetic.

    So it probably has something to do with it. Try incrementing nsize by nsize += 4096/sizeof(int) or something more clever.

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

Sidebar

Related Questions

Here is my practice code: int integer_part; char* string_part = (char*)malloc(sizeof(1000)); char* input_string =
CODE : int *Array[8]; Array[0] = (int *) malloc(sizeof(int) * 5); printf(%d , sizeof(Array)/sizeof(int));
I test the following code: char ch,z=120; int x=5; double y=7.5; printf(\nsize of (z+100):
This is my code: int main(int argc, char *argv[]){ FILE *fp; char *tmp, *tmp2,
Why does this code int (*g)(int); int (*h)(char); h = g; In C, give
This is my code: int main(void) { int i, j, k, n; char userLatter,
On running the following code: int main() { int a = sizeof(signed) + sizeof(unsigned);
I have the following code: int get_int(void) { char input[10]; fgets(input, 10, stdin); //
Having code: int** a = new int*[2]; a[0] = new int(1); a[1] = new
Example code : int main() { std::vector<int> v1{1, 2, 3, 4, 5, 6, 7,

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.