Hum I looked at that tutorial too. How do I work with 3-dimensions arrays then? :)
Printable View
Hum I looked at that tutorial too. How do I work with 3-dimensions arrays then? :)
i'd do it this way (multidimensioned arrays are singledimensioned arrays in a way)
*(first+index1+index2*dim1+index3*dim2*dim1)
others might do
*first[index1+index2*dim1+index3*dim2*dim1]
if you use static arrays, you can declare them as follows:
datatype myarray[6,4,3]
and refer to element i1,i2,i3 with
myarray[i1,i2,i3]
you can use this multidimensional expression only if the arrays are static, since the compiler will know the dimensions and fill them in.
Hum, I think I'll use the first one you suggested ;)
If I wanted to do something that in VB would look like this:
Array1(x,y) = Array2(x,y,z)
How could I do it in C++? The asterisk only lets me point to one at a time, right?
C++ does indeed rock. What other language can do this?
And yes.... It runs... mwuahahahahah.Code:#include <iostream.h>
#define Begin void main() {
#define end }
#define and &&
#define if if(
#define then )
#define writeln(x) cout << x << endl;
Begin
if (1 < 2) and (2 < 3) then writeln("Hello World!");
end
Z.
Cool, Zaei!
Anyway I think I figured it out... all I'd have to do would be use the first element of the array as "first" in the formulae, right?
i think it's better to stay with the orignal language, others might wonder what kind of programmer you really are :p
the asterix is used to dereference the pointer, so if you want to assign the element, dereference it
Yeah. You can do some whacky stuff with #define...
Z.Code:#include <iostream.h>
#define This void main() {
#define code int x; cout << "Enter a value: ";
#define is cin >> x;
#define really if(x <= 5) cout << x << endl;
#define very if(x > 5) cout << x +1 << endl;
#define wierd }
This code is really very wierd
???:confused:???
You got me lost on that one, keda! What do you mean?
*testing my own knowledge*
do you mean like when you have a pointer to an object, you get the object data back from the pointer?
(did I pass? :D)
Heh, maybe that's it, because I was passing it the first element of the array and I wanna read from that position on...
PsychoMark knowledge test :) Yes, that's correct.
if you have a pointer to a variable it contains the address of the variable, not the object itself, the pointer is usually 4 bytes. If you do operations directly on the pointer, the address will change, for instance
int[4] array={1,2,3,4};
int* ptr=int[2];
cout << ptr << endl; //shows an address
cout << *ptr << endl; //shows 3
ptr--; //moves pointer backwards
cout << *ptr << endl; // shows 2
ptr+=2; //moves pointer forward 2 steps
cout << *ptr << endl; // shows 4
Whoo hoo! Now where's the car I just won? :p
Look, I just need some working code for a 3-d array, ok? :)
Code:long x[3][3][3];
x[0][0][0] = 0;
x[0][2][1] = 5;
Thanks Parksie - but the only problem is that the array is passed to it in the function's arguments, and I don't know its exact size :(
Anyway, I already found someone who will code it in Asm! But he's still not sure if he's gonna make it so thanks for your help (I might need it later) ;)
so go with pointers jotaf ;) that is in case your asm assistant decides to dump you (who is it if i may ask?) :)