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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:30:44+00:00 2026-05-16T06:30:44+00:00

Why the array is not overflowed (e.g. error alert) when the array is declared

  • 0

Why the array is not overflowed (e.g. error alert) when the array is declared globally, in other why I’m able to fill it with unlimited amount of elements (through for) even it’s limited by size in declaration and it does alert when I declare the array locally inside the main ?

char name[9];


int main(){


    int i;


    for( int i=0; i<18; ++i){
    cin>>name[i];


    }

    cout<<"Inside the array: ";
    for(i=0; i<20; i++)
    cout<<name[i];

    return 0;

}
  • 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-16T06:30:45+00:00Added an answer on May 16, 2026 at 6:30 am

    C++ does not have array bounds checking so the language never check to see if you have exceeded the end of your array but as others have mentioned bad things can be expected to happen.

    Global variables exists in the static segment which is totally separate from your stack. It also does not contain important information like return addresses. When you exceed an array’s boundaries you are effectively corrupting memory. It just so happens that corrupting the stack is more likely to cause more visible bad things than corrupting the data segment. All of this depends on the way your operating system organizes a process’s memory.

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

Sidebar

Related Questions

Trying to count how many elements within the array are not equal to 0,
Why does the array a not get initialized by global variable size ? #include<stdio.h>
When you do Something.find(array_of_ids) in Rails, the order of the resulting array does not
I've got a string (not an array, it's a load of words stored in
I'd like to perform metrics on the contents of an array that do NOT
Is there any way to create a variable sized doubly-scripted array in C (not
VisualPHPUnit test. No, it's not an array. class TestGetChildren extends PHPUnit_Framework_TestCase { protected $objs;
Native Array in Emberjs does not support deep copy? I saw it just returning
I'm not sure if the array is too deep or what, but I can't
I'm getting a stack overflow error on some, but not all, IE7 machines. This

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.