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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:53:06+00:00 2026-06-18T11:53:06+00:00

Some simple code doesn’t appear to be working, and I’m not sure why. I’m

  • 0

Some simple code doesn’t appear to be working, and I’m not sure why.

enter image description here

I’m dynamically creating an array of integers. The size of this array is shown as 15, but that’s just because I’m trying to debug the program. The actual size is variable at runtime.

I browsed a few sites for how to dynamically create an integer array in C++. Sites like this one came up. Their code looks like my code: an array is created, and a for loop sets the value of each element in the array.

But after my for loop runs, I get an array of size 0. What could be the problem?

This is an extremely basic C++ program compiling on Windows using Visual Studio.

  • 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-18T11:53:07+00:00Added an answer on June 18, 2026 at 11:53 am

    The debugger doesn’t know it’s a pointer to the start of an array, it thinks you have a plain pointer to an int (since that is the type of array: int*). So it shows the value of that int (the first element in the array), which is 0 here.

    Your code is fine; you have indeed allocated (and initialized) an array of 15 ints correctly.

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

Sidebar

Related Questions

Why doesn't object.__init__ take *args, **kwargs as arguments? This breaks some simple code in
This is some simple code that draws to the screen. GLuint vbo; glGenBuffers(1, &vbo);
I was just writing some simple code and I noticed that using document.writeln doesn't
i have some simple code that does a preg match: $bad_words = array('dic', 'tit',
This simple code is not producing any sound on a couple of machines that
Can anyone understand why this simple code doesn't work: <script src=/jQuery/jquery-1.7.2.min.js type=text/javascript></script> <script type=text/javascript>
I have some simple code like this: <?php setcookie(user,test, time() + 3600); echo $_REQUEST['user'].<br>;
Below is some sample code. The window does not resize (python3.2, on a Mac,
Some simple code: - (IBAction)Up_Down:(UIStepper *)sender { double value = [sender value]; [NumDayLabel setText:[NSString
Here is some simple code: DIR* pd = opendir(xxxx); struct dirent *cur; while (cur

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.