How to declare this array?

This is a discussion on How to declare this array? within the C++ Programming forums, part of the General Programming Boards category; I define this data in header file. --------------------------------------------------- #define Hash[0] "208803DD4D" #define Hash[1] "146DB1CB1C" #define Hash[2] "26D2199CFA" #define Hash[3] "7CAFF3D504" ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    68

    Lightbulb How to declare this array?

    I define this data in header file.

    ---------------------------------------------------
    #define Hash[0] "208803DD4D"
    #define Hash[1] "146DB1CB1C"
    #define Hash[2] "26D2199CFA"
    #define Hash[3] "7CAFF3D504"
    #define Hash[4] "6C40AB0E42"
    #define Hash[5] "1E1D7486BE"
    #define Hash[6] "A03E54D487"
    #define Hash[7] "7ACC08F3F7"
    #define Hash[8] "6B0133E813"
    #define Hash[9] "114CFE0C12"
    ---------------------------------------------------

    when I compile there is error message show
    "error C2008: '[' : unexpected in macro definition"

    If you know how to declare these array in header file,please tell me. Thank you.

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Do you want these as strings or ints?
    Code:
    double Hash[] = {
    		0x208803DD4D, 
    		0x146DB1CB1C,
    		0x26D2199CFA,
    		0x7CAFF3D504,
    		0x6C40AB0E42,
    		0x1E1D7486BE,
    		0xA03E54D487,
    		0x7ACC08F3F7,
    		0x6B0133E813,
    		0x114CFE0C12
    	        };
    
    char *Hash[] = {
    		"208803DD4D", 
    		"146DB1CB1C",
    		"26D2199CFA",
    		"7CAFF3D504",
    		"6C40AB0E42",
    		"1E1D7486BE",
    		"A03E54D487",
    		"7ACC08F3F7",
    		"6B0133E813",
    		"114CFE0C12"
    
    	       };

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Code:
    namespace
    {
    const char* Hash[] =   {"208803DD4D",
                            "146DB1CB1C",
                            "26D2199CFA",
                            "7CAFF3D504",
                            "6C40AB0E42",
                            "1E1D7486BE",
                            "A03E54D487",
                            "7ACC08F3F7",
                            "6B0133E813",
                            "114CFE0C12"};
    }
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. Declare Multi-Dimensional Array
    By hondaccord94 in forum C Programming
    Replies: 14
    Last Post: 07-27-2006, 08:36 AM
  3. 1-D array
    By jack999 in forum C++ Programming
    Replies: 24
    Last Post: 05-12-2006, 07:01 PM
  4. 2d array question
    By gmanUK in forum C Programming
    Replies: 2
    Last Post: 04-21-2006, 12:20 PM
  5. Replies: 4
    Last Post: 02-02-2003, 04:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21