User Tag List

Results 1 to 2 of 2

Thread: SizeOfArray() issue

  1. #1
    Here lies mero. Died by his own dumbassitude.
    Join Date
    May 2011
    Posts
    929
    Mentioned
    102 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    5,527
    Level
    23
    vBActivity - Bars
    Lv. Percent
    13.96%

    Not A Bug SizeOfArray() issue

    I tried doing this:
    PHP Code:
    int var = 1;
    if(
    SizeOfArray(var)==-1)
        
    Link->Item[I_SWORD1]; 
    Worked just find, except that it traced an error message in allegro.log saying that it tried to pass the value of var as an index into the array; returns -1 regardless of what number you put in as it should since it's not an array.

  2. #2
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,432
    Level
    24
    vBActivity - Bars
    Lv. Percent
    70%
    There's no way to make it work. If you modify your code as follows:
    Code:
    int arr[5];
    int var = 1;
    if(SizeOfArray(var)==-1)
        Link->Item[I_SWORD1];
    you'll find that SizeOfArray(var) is 5, because arr==var (assuming there weren't any other arrays already). An array pointer is just a number, so an arbitrary number may well be a valid array pointer. There isn't a way we could distinguish between arrays and numbers without fundamental changes to the language.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social