array question
ok, i have an array like this:
char myarray[] =
{
0,0,0,0,0,
0,0,0,0,0,
0,0,1,0,0,
0,0,0,0,0,
0,0,0,0,0,
};
ok, see the 1 in my array? if i wanted to change the value of that 1 to a 0, how would i do that?
you could use
myarray[12] = "0";
you have to start counting with 0, so it's the 12th field
Edited by - Tuvok on May 20, 2000 5:45:06 AM
myarray[12] = "0";
you have to start counting with 0, so it's the 12th field
Edited by - Tuvok on May 20, 2000 5:45:06 AM
I believe this would do the trick:
myarray[12] == 0;
Someone may want to correct me though as I am a VB person
"Only a fool quotes himself"
Andy Owen
My Homepage (Non games related)
My Current Project (Games related... I think)
myarray[12] == 0;
Someone may want to correct me though as I am a VB person
"Only a fool quotes himself"
Andy Owen
My Homepage (Non games related)
My Current Project (Games related... I think)
You could:
Edited by - DerekSaw on May 20, 2000 5:53:07 AM
1) myarray[12] = 0; // not '== 0'2) myarray[12] = '\0'; // not "0"3) .... go figure.
Edited by - DerekSaw on May 20, 2000 5:53:07 AM
Ragonastick; you do need to be corrected...
The double equals (==) is an eqaulity test in C.
Not an assignment.
The assignment is just a single equals (=)
Tuvok on the other hand, is almost there.
Just one little gripe, single quotes should be
used, not speech marks.
The final version:
myarray[12] = ''0'';
Now, gpw, why are you creating an array of chars with numbers in it?
Just curious, thats all.
The double equals (==) is an eqaulity test in C.
Not an assignment.
The assignment is just a single equals (=)
Tuvok on the other hand, is almost there.
Just one little gripe, single quotes should be
used, not speech marks.
The final version:
myarray[12] = ''0'';
Now, gpw, why are you creating an array of chars with numbers in it?
Just curious, thats all.
oops, the "char" part of my code was a type-o. i meant to type "int". thanks for the help, everyone!
quote:Original post by Mezz
The final version:
myarray[12] = ''0'';
myarray[12] = ''0''; will set it to a zero character... not zero value. It should be myarray[12] = ''\0'';
Typo error maybe?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement