# Displaying an array (concept not a how to)

Printable View

• 11-29-2005
mrcheesypants
Displaying an array (concept not a how to)
The other day I decided to start a program that solves soduku puzzles on the account that I had just learned C++ and I thought it would be a good "out of the books" exercise. While writing some pseudocode I got bored and decided to run the following code to see what happens:
Code:

```#include <iostream> using namespace std; int main(){ int sudoku[10][10]; cout<< sudoku; cin.ignore(); return 0; }```
When I ran the program I got this:
0x22fde0

Can someone tell me what that means? The curiosity will kill me if I don't find out.
• 11-29-2005
Daved
sudoku is an array. When you attempt to output an array, the variable name (sudoku) is considered to be a pointer to the first element. The pointer value is output. Pointers are output in hex format, and so that is what was printed.

You'd have to write extra code to display each value in the array (which of course is not yet initialized).
• 11-29-2005
mrcheesypants
So im assuming that the number I got was the memory address then?

EDIT: wait what does the "0x" mean? 0 times that hex number?
• 11-29-2005
major_small
yes, that's the memory address, and 0x denotes a hex number. for example, 0x5 is hex 5.
• 11-29-2005
jlf029
You must use a loop (for or while) that will iterate through each element
• 11-29-2005
7stud
Quote:

EDIT: wait what does the "0x" mean? 0 times that hex number?
We have to have some way of notifying each other what base a number is represented in. By convention, a number like:

16

is considered a decimal number. You could write that decimal number in hex like this:

10

but how do other people, and especially computers, know that should be considered a hex number and not decimal number? To signal that a number is represented in hex, you prefix it with "0x":

0x10