0
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{


    const int SIZES = 4;
    int oldvalues[SIZES] = { 10, 100, 2000, 300 };
    int newvalues[SIZES];



    for (int count = 0; count < SIZES; count++)
        newvalues[count] = oldvalues[count];
    cout << newvalues << endl;

}

Is there a reason my code is only printing "0x7ffeefbff270" I don't think there is anything missing. My guess is that I have the cout wrong?

2 Answers2

0

When printing out values of an array, you have to specify each element you want to print. You can't print the whole thing at once.

You should put brackets for your for loop (always use brackets!) and include your cout line within those brackets. Then update the cout line to reference the element you just saved - newvalues[count].

Gilvar
  • 36
  • 2
0

Just trying to print the array is giving you a memory address.

#include <iostream>

int main()
{
    const int SIZES = 4;
    int oldvalues[SIZES] = { 10, 100, 2000, 300 };
    int newvalues[SIZES];


    for (int count = 0; count < SIZES; count++)
        newvalues[count] = oldvalues[count];

    for (int count = 0; count < SIZES; count++)
        std::cout << newvalues[count] << " "; # Here you need to indicate each element
}

ptan9o
  • 174
  • 9