1 registered members (Ayumi),
1,170
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
How to pass var pointer?
#298306
11/13/09 17:54
11/13/09 17:54
|
Joined: Jan 2007
Posts: 2,247 Deutsch Niedersachsen
Puppeteer
OP
Expert
|
OP
Expert
Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
|
function test(var* bla)
{
bla=2;
}
var asd=0;
test(asd);
error(str_for_num(NULL,asd));
this doesnt work (asd!=2). why?
Last edited by Puppeteer; 11/13/09 17:55.
|
|
|
Re: How to pass var pointer?
[Re: Sepiantum]
#298455
11/15/09 08:02
11/15/09 08:02
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
when you say test(asd); and use asd as a pointer, lite-c understands that and gives you it's pointers, so when you are using lite-c functions you GENARALLY wont need the preceeding &. Altough lite-c is fully compatible with ANSI-C, lite-c is not ANSI.
(so you can both pass a VECTOR or a VECTOR* to a function that takes VECTOR* as parameter)
Last edited by Quadraxas; 11/15/09 08:04.
3333333333
|
|
|
Re: How to pass var pointer?
[Re: Sepiantum]
#298568
11/16/09 03:07
11/16/09 03:07
|
Joined: Jan 2007
Posts: 2,247 Deutsch Niedersachsen
Puppeteer
OP
Expert
|
OP
Expert
Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
|
void make_identity_matrix(var* mat)
{
int i,j;
for( i= 0 ; i< 4 ; i++ )
for( j= 0 ; j< 4 ; j++ )
{
if(i==j)
{
*mat[i][j]=1;
}
else
{
*mat[i][j]=0;
}
}
}
compiler says "dimension of array error." in "*mat[i][j]=1;" and "*mat[i][j]=0;" Whats wrong here? Maybe because he is only passing a pointer to a single var in an array? (but (var** mat) doenst work too)
Last edited by Puppeteer; 11/16/09 03:09.
|
|
|
|