What's wrong with this code?


One of the main purposes of this code is that it's supposed to ask the user to enter a number for the length of an array, and then enter the values of the array, so let's say you enter 5 for the array size, you would have to enter the 5 values.
When I enter any of these numbers, it displays this:
-842150451, -842150451, -842150451, -842150451, Enter an integer to append to the end of the array.
Then when I enter an integer, it displays the same 4 numbers again, before closing..
I don't know what's wrong..
I don't believe the problem lies in my class header or source file, so I won't need to post those.
Last edited on
You're allocating your array's but you're not setting any values so they just contain garbage.
Hey, can you be more specific please?
Thanks
You create 'numPtr' on Line 58, you allocate space for it to point to on Line 63, then you immediately send it to your printArray() function on Line 64. At no point in the objects life time do you actually assign a value to anything.
Correct me if i'm wrong but you assign the value on line 61, where you enter in the number you want for "num"
Last edited on
Well that was not the problem at all. I figured out that all I needed was another for loop under line 63.
Topic archived. No new replies allowed.