Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

An array function in Irrlicht

Name: Anonymous 2012-09-16 11:58

I'm trying to run a function which uses a 2d array as a parameter, and it's giving me shit most of the time.

Explicitly, I'm using Irrlicht's 2d graphicsdemo (#6), I create a 2d array of int *myarray[4][4];, my function is:

    void initmyarray(int *thisarray[4][4])
    {
        int x, y = 0;
    for(x=0;x < 5; ++x)
    {for(y=0; y < 5;++y )
        {
            thisarray[x][y] = 0;
        }
    };
    };

I run the declaration (or whatever) and function as initmyarray(myarray2); before the while(device->run() && driver) runs, and after     driver->getMaterial2D().AntiAliasing=video::EAAM_FULL_BASIC; runs, and although I can finally get the program to compile, and it makes the animated imps blink after each loop. I tried renaming initarry and myarray obviously, but after trying to pass arguments and shit properly this happens. If I comment out initmyarray(myarray2); the imps animate properly.



Suggestions? I'll use vectors if I have to, I'm just trying to make a 2d grid with which I can do shit.

I'm running Code::Blocks with MingW, and the only build option is produce debugging symbols.

Name: Anonymous 2012-09-16 12:16

You forgot code tags.

Also, why the hell are you asking for advice in 4chan?

Name: Anonymous 2012-09-16 12:20

>>2
The text boards retain enough formatting, it's not like I'm using Python.

Name: Anonymous 2012-09-16 14:04

So I managed to find the error

    int *myarray2[4][4];
    initmyarray(myarray2);
    core::rect<s32> imp1(349,15,385,78);
    core::rect<s32> imp2(387,15,423,78);

works without imps blinking

but

    core::rect<s32> imp1(349,15,385,78);
    core::rect<s32> imp2(387,15,423,78);
    int *myarray2[4][4];
    initmyarray(myarray2);

doesn't.

I removed some extraneous semicolons from my initmyarray function, had no effect but is proper I think. Guess I have to look into rect to see if it fucks with existing arrays or something, I don't know.

Name: Anonymous 2012-09-16 14:41

Nevermind, I was passing the array as a pointer WHEN IT WAS ALREADY FUCKING PASSING IT AS A POINTER so I would've had to double dereference and shit.

Name: Anonymous 2012-09-16 15:06

void initmyarray(int *thisarray[4][4])

I was wondering why the fuck you had that.

Name: Anonymous 2012-09-16 22:00

Use APL instead.
4 4⍴0
Look at that: a 4 by 4 matrix of zeroes.

Name: Anonymous 2012-09-16 23:59

>>6
The last dimension of an array is necessary when passing a multidimensional array as a function, I just through in the other dimension so I wouldn't have to worry if C++ was fucking around with something I didn't know.

Turns out another bug shows up: I made a function to print my array, and I think I found out at least part of why the imps fuck up. The first three dimensions of imp2 enter my array at some point at the last three memory locations (5, 3-5), if the array is initialized before the imp rectangles are made. Afterwards probably interferes with the imp memory or something which is why it takes a shit. I'm filing a report with Sourceforge tomorrow because that shit is dumb.

Name: Anonymous 2012-09-17 1:50

>>8
I'm just confused why you're passing in an 2D array of int pointers and then assigning the integer zero to them. I think you fucked up and meant to instead write
void initmyarray(int thisarray[4][4])

Name: >>9 2012-09-17 1:52

>>1,8
ALSO, you're going out of bounds... come on. You're iterating 0 to 4 inclusive (ie 5 numbers) on the array that has 4 spots in each dimension. I'm just starting to think you don't understand C++ at all in which case please don't try making a game.

Name: Anonymous 2013-09-01 17:10


This sequence starts with the natural numbers including zero (finite cardinals), which are followed by the aleph numbers (infinite cardinals of well-ordered sets). The aleph numbers are indexed by ordinal numbers. Under the assumption of the axiom of choice, this transfinite sequence includes every cardinal number. If one rejects that axiom, the situation is more complicated, with additional infinite cardinals that are not alephs.

Name: Anonymous 2013-09-01 19:27


For example, the empty set is assigned rank 0, while the set {{}} containing only the empty set is assigned rank 1. For each ordinal α, the set Vα is defined to consist of all pure sets with rank less than α. The entire von Neumann universe is denoted V.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List