-2

I'm not sure what I'm doing incorrectly here, but when I compile this program, the console output shows all of the data as strange corrupted characters and what seems to be hex numbers.

Here's the source:

#include "stdafx.h"

#include <iostream>

using namespace std;

int main()
{
    int x[10] = { -5, 4, 3 };
    char letters[] = { 'a', 'b', 'c' };
    double z[4];

    cout << x;
    cout << "\n";
    cout << letters;
    cout << "\n";
    cout << z;
    cout << "\n";
    system("pause");
    return 0;
}

Here's how it compiles - https://gyazo.com/a622959f6b6e88846ce5d1d922c8c356

Thanks in advance.

1 Answers1

0

You are printing the pointer of the array for x and z which gives you a hex address if you want to print the values you need to loop through it and use the index operator [] like this

for (int i = 0; i < some number; i++) { cout << x[i];}

Also it would appear that z is empty in this example.

TyAnthoney
  • 278
  • 4
  • 12