Thread: Displaying an array (concept not a how to)

  1. #1
    Registered User
    Join Date
    Sep 2005

    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:
    #include <iostream>
    using namespace std;
    int main(){
    int sudoku[10][10];
    cout<< sudoku;
    return 0;
    When I ran the program I got this:

    Can someone tell me what that means? The curiosity will kill me if I don't find out.

  2. #2
    Registered User
    Join Date
    Jan 2005
    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).

  3. #3
    Registered User
    Join Date
    Sep 2005
    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?

  4. #4
    Registered User major_small's Avatar
    Join Date
    May 2003
    yes, that's the memory address, and 0x denotes a hex number. for example, 0x5 is hex 5.
    Join is in our Unofficial Cprog IRC channel
    Channel: #Tech

    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  5. #5
    Registered User
    Join Date
    Nov 2005
    You must use a loop (for or while) that will iterate through each element

  6. #6
    Registered User
    Join Date
    Apr 2003
    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:


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


    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":

    Last edited by 7stud; 11-29-2005 at 06:53 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. question about multidimensional arrays
    By richdb in forum C Programming
    Replies: 22
    Last Post: 02-26-2006, 09:51 AM
  3. Template Array Class
    By hpy_gilmore8 in forum C++ Programming
    Replies: 15
    Last Post: 04-11-2004, 11:15 PM
  4. two dimensional dynamic array?
    By ichijoji in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2003, 04:27 PM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM