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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:33:31+00:00 2026-06-05T13:33:31+00:00

Another student asked me what could be wrong with his C code. I successfully

  • 0

Another student asked me what could be wrong with his C code. I successfully reproduced the erroneous behavior and have completely no idea why this segfaults. Consider this tiny C programm:

#include <stdio.h>

int main(void) {
    int N = 590;
    double A[N][N];
    double B[N][N];
    double C[N][N];
    printf("done");
}
  • Set N to a value <= 590:
    This runs without errors, with or without output.
  • set N to a value > 590:
    • Runs flawlessy with output line removed.
    • Compile and run with output: segmentation fault

What’s the reason for this? Can anybody explain?

  • 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-05T13:33:32+00:00Added an answer on June 5, 2026 at 1:33 pm

    You try to allocate more memory than it’s available on the stack which causes stack overflow. Usually it is much better to allocate huge arrays like that dynamically by using malloc, calloc or realloc. Don’t forget to free this memory by calling free when you finish with it 🙂

    These questions will help you too:
    C/C++ maximum stack size of program
    Segmentation Fault on creating an array in C
    Segmentation Fault When Using Variable To Initiate Array

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

Sidebar

Related Questions

Some student asked this on another site, but got no answers. I had a
I have a model called user and another model called student. Neither of them
Another simple question. I found this really cool snippet of code: $date_str = Jan
Another question related to this one . I have a List<SortableObjects> that is the
My boss just asked me to integrate his bosses old Fortran code into a
I have a Student table which should have name column. But I made another
Back again with another Flex question. I have an XML structure like... <Student> <Name>X</Name>
Can someone explain to me why this code prints 14? I was just asked
I know this has been asked before but I have looked at every answer
I'm a student and I have a semester paper called 'GRID COMPUTING' and another

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.