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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:17:12+00:00 2026-05-28T04:17:12+00:00

I have been running this random walk simulation for a while now and I

  • 0

I have been running this random walk simulation for a while now and I keep getting an error EXC_BAD_ACCESS from Xcode. Its printing out a large part of the simulation though.

I think its running out of memory for some reason but I am not sure why.

If I go towards the end of the array I edited it so I don’t get within 100 spaces of the edge (by editing the variable steps to steps -100). This works but I would like to know whats going on.

Any help would be appreciated.

double** places;  
places = (double**) malloc(steps*sizeof(double*));  
for (int i = 0; i < steps; i++)places[i] = (double*) malloc(2*sizeof(double));  

for (i = 0; i< steps/*, exit*/; i++) {
    // Find the angle of movement 
    angle = getRand()*360; 
    // Take a step
    xPos+= STEP*cos(angle);
    yPos+= STEP*sin(angle);
    //Write Step to array
    places[i][1] = xPos;
    places[i][2] = yPos;
    //Write Step to File
    fprintf(ff, "%d %lf %lf\n",i,xPos,yPos);
}
  • 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-28T04:17:12+00:00Added an answer on May 28, 2026 at 4:17 am

    Array indexes start at zero.

    Did you mean to write this?

        places[i][0] = xPos; //Zeroth element is considered the first element
        places[i][1] = yPos; //Second element
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been running this code (from: http://blog.somethingaboutcode.com/?p=155 ): from twisted.internet import reactor from
I have been running into this error for the last 3 or 4 weeks
This is a bit of a vague notion which I have been running over
I have been using win32api.MessageBox to do alerts, and this works for apps running
I have been running SQL Server 2005 Express Management Studio (SSMSE), and I now
I have been running Visual Studio 2008 Team Edition for some time now and
We have been getting a range on infuriating error dialogs using Visual Studio 2008
I have this situation that is really irritating me now. At random times with
I've been ripping my hair out for a while now with these random numbers
I have been running Apache HTTPD in 64bit mode by stripping out the 32bit

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.