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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:59:02+00:00 2026-05-24T01:59:02+00:00

int d; cin >> d; int asdf[d]; Is this considered dynamic memory allocation? According

  • 0
int d;
cin >> d;
int asdf[d];

Is this considered dynamic memory allocation? According to http://www.cplusplus.com/doc/tutorial/dynamic/, it seems like I shouldn’t even be able to compile this, because arrays without using the new operator can only be declared with constant size, maybe I read it wrong. (I’m using CodeBlocks with GNU CCC compiler)

What is the difference between that and

int d;
int *asdf;
cin >> d;
asdf = new int[d];

Is the only difference that array created using new lives until it is deleted, whereas the first array becomes freed as soon as you leave the scope?

  • 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-24T01:59:04+00:00Added an answer on May 24, 2026 at 1:59 am

    int x[n]; is a variable-length array (VLA), which has automatic storage duration (i.e. “on the stack”). It is not valid in C89 or C++98/03, but it was introduced in C99 and is commonly available as an extension, e.g. in GCC.

    The functionality can also be mimicked on some platforms with the non-standard alloca() function, which was used before VLAs became common.

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

Sidebar

Related Questions

i want to do what the title says like this: int number1; cin>>number1; num1len=log10(number1)+1;
how would you code this in Java? char c; int n; cin >> c
Salute.. Let's see this example: int x,y,s; cin>>x>>y; s=x+y; here we have three variables
This is my main program, int main () { string command; cin>>command; if(command ==
int x = n / 3; // <-- make this faster // for instance
I have a int var; and using cin, but how to check if user
I have the following code: ... int n; cin >> n; int numbers[n]; ...
#include <iostream> #include <string> using namespace std; int main(void) { string a; cin>>a; a.erase(a.end()-1);
int n; std::cin >> n; std::string s = ; std::getline(cin, s); I noticed that
int i,j; std::string s; std::cin>>i>>j>>s>>s>>i; std::cout<<i<< <<j<< <<s<< <<i; Question Referring to the sample

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.