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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:31:22+00:00 2026-06-18T21:31:22+00:00

I am getting a segmentation fault when I try to call a class function

  • 0

I am getting a segmentation fault when I try to call a class function in my program. During my program, the matrix grid[][] changes rapidly, and I want to be able to at a certain time save an “image” of the grid, so that I can compare later versions of the grid to this reference. So when I try to save the “image” of grid[][] to the reference matrix, I simply copy all of the values to it using a for loop. I did a couple tests during my program and I seem to be getting a segmentation fault during the getreference function.

class lattice
{
public:
    lattice(){} // Constructor
    ~lattice(){} // Destructor
    void getgrid(){...}

    //Other functions...

    void getreference()
  {
    for(int a = 0; a<SIZEX; a++)
    {
        for(int b = 0; a<SIZEY; b++)
        {
            reference[a][b] = grid[a][b];
        }
    }
  }

private:
    short grid[SIZEX][SIZEY];
    short reference[SIZEX][SIZEY];
}
  • 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-18T21:31:23+00:00Added an answer on June 18, 2026 at 9:31 pm
    for(int b = 0; a < SIZEY; b++)
    

    should be

    for(int b = 0; b < SIZEY; b++)
    

    That’s why you got a segmentation fault.

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

Sidebar

Related Questions

I am getting a strange segmentation fault in my program. Dlist is a class
I am getting a segmentation fault error when I try to run my program
When I try to execute this program I am getting segmentation fault. What could
I am getting a segmentation fault from bash when I try to SSH to
I'm getting a segmentation fault the first time I call malloc() after I protect
I'm getting a segmentation fault everytime i want to run this code : from
I'm getting a segmentation fault saying core dumped . The C++ program is to
I'm trying to delete whole linked list but getting segmentation fault and not able
I'm getting a segmentation fault when I try to do pthread_mutex_lock(&_mutex). This is really
Im getting segmentation fault from pthread_mutex_lock, heres my backtrace: Program received signal SIGSEGV, Segmentation

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.