array question

Started by
5 comments, last by gameprogrammerwiz 23 years, 11 months ago
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?
==============================
whats a signature?
htm[s]l[/s]
Advertisement
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
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)
Trying is the first step towards failure.
You could:
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
"after many years of singularity, i'm still searching on the event horizon"
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.
oops, the "char" part of my code was a type-o. i meant to type "int". thanks for the help, everyone!
==============================
whats a signature?
htm[s]l[/s]
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?

"after many years of singularity, i'm still searching on the event horizon"

This topic is closed to new replies.

Advertisement