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

  • Home
  • SEARCH
  • 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 3852584
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:20:22+00:00 2026-05-19T17:20:22+00:00

I need to parallelise an application using win32 threads. One of the portions of

  • 0

I need to parallelise an application using win32 threads. One of the portions of the code involves modifying an static array using threads.

I pass the array as a parameter like this:

struct threadParameter {
   float **array;
   int row;
}

An example code would be like this:

// Main

float data[100][100]

for (int i = 0; i < 100; i ++) {
   tp = (*threadParameter) new threadParameter;
   tp->array = (float **) data;
   tp->row = i;
   AfxBeginThread... // Begin thread code
}

// Thread Code

UINT myThread(LPVOID param) {

    threadParameter *pp = (threadParameter *) param;
    for (int j = 0; j < 100; j ++) {
      pp->array[pp->row][j] = NEWVALUE;
    }
}

However, when executing the project, I get an “Access Violation Error” when I try to acceess the array via the **array pointer. This problem does not occur if the array data is
dynamic. Is there any way to sort this problem out (I am not allowed to change the array data from static to dynamic)?

  • 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-19T17:20:22+00:00Added an answer on May 19, 2026 at 5:20 pm

    Static arrays are NOT pointers to pointers — the entire array is a single huge chunk of data, and addressable with a single pointer, namely, the pointer to the base of the array. Hence

    tp->array = (float **) data;
    

    is incorrect, because you’re dereferencing a number inside the array. (The fact that you needed to cast also should’ve raised a red flag, since arrays are implicitly converted to the appropriate pointer types.)

    That’s why the common phrase “arrays are just pointers” is incorrect; it’s half-true for single-dimensional arrays, but completely false with multidimensional arrays. If you need to use two indices, convert a single index into a row-column index by multiplying the row by the row size, then adding the column and indexing into the array with a pointer.

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

Sidebar

Related Questions

Need some regular expressions help. So far I have my code working to allow
I'm trying to a parallelize an application using multiprocessing which takes in a very
I am working on a project where we need to parallelize this problem using
I desperately need some help on this one. I've created a <script> that closely
I have an application that has multiple threads processing work from a todo queue.
Here's the sample C code that I am trying to accelerate using SSE, the
Our application is using JCS for caching frequently used data. I wanted to know
I need to take a large array of doubles, and process it in chunks
I am using a WDF Service in my web application which I am accessing
I'm working on a little application that multiples an array with a Matrix. It

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.