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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:51:29+00:00 2026-06-14T19:51:29+00:00

I have read this paragraph from here: http://www.cplusplus.com/doc/tutorial/dynamic/ You could be wondering the difference

  • 0

I have read this paragraph from here: http://www.cplusplus.com/doc/tutorial/dynamic/

You could be wondering the difference between declaring a normal array
and assigning dynamic memory to a pointer, as we have just done. The
most important difference is that the size of an array has to be a
constant value, which limits its size to what we decide at the moment
of designing the program, before its execution, whereas the dynamic
memory allocation allows us to assign memory during the execution of
the program (runtime) using any variable or constant value as its
size.

But this code of mine works just fine:

int number;
cin>>number;
int myArray[number];

cout<<sizeof(myArray)/sizeof(myArray[0])<<endl;
cout<<sizeof(myArray)<<endl;

Does this mean the array is created in dynamic memory? Or is it created in static memory but the size of it still determined in runtime?

  • 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-14T19:51:31+00:00Added an answer on June 14, 2026 at 7:51 pm

    As I pointed out in a comment, but here with more detail.

    In standard C++ the size of an array has to be known at compile time. In your example this is not the case. Your code compiles because you are (presumably) using gcc with the variable length array extension enabled.

    Setting your warning level correctly will prevent this code from compiling.

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

Sidebar

Related Questions

I have read from this article http://codahale.com/how-to-safely-store-a-password/ and it says using a salt isn't
I have read this article from High Scalability about Stack Overflow and other large
I have read this in order to compile NH spatial for Nhibernate 3.1 http://build-failed.blogspot.it/2012/02/nhibernate-spatial-part-2.html
Link to site in question: http://www.christopherwarrington.com/testing_ground I have a start screen that is set
From the following paragraphs of Text—— (http://developer.yahoo.com/hadoop/tutorial/module2.html),It mentions that sequential readable large files are
I have read this question and the simple and clear answer but it's not
I have read this thread when I got the the git: command not found
I have read this question but it's not quite what I was looking for.
I have read this article about 400% boost of your website . This is
I have read this. Jquery checkbox <input type=checkbox name=checkGroup id=all> <input type=checkbox name=checkGroup id=one

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.