|
Post by fwiss on Jan 28, 2011 10:22:15 GMT -5
My while function doesn't redefine(initialize) it, does it? I'm just trying to test the third element of an array.
|
|
|
Post by DJLinux on Jan 29, 2011 4:00:52 GMT -5
My while function doesn't redefine(initialize) it, does it? if have this pseudo code if this int name[3] = {aa,bb,cc}; else if that int name[3] = {bb,cc,aa}; else int name[3] = {cc,aa,bb}; the compiler will see 3 diffrent array defines with same name and should give you warnings (warnings should be enabled of course) i'm sure in C (and may be C++ too) you have to use it like this int name[3]; // only once
if this name[0] = aa; name[1] = bb; name[2] = cc; elseif that name[0] = bb; name[1] = cc; name[2] = aa; else name[0] = cc; name[1] = aa; name[2] = bb; (sorry if i'm wrong but you can give it a try) Joshy
|
|
|
Post by Supermonkey on Jan 29, 2011 11:20:37 GMT -5
What DJ said is correct, you need to read about variable scope.
|
|
|
Post by fwiss on Jan 29, 2011 11:20:54 GMT -5
I get the same warning I had three posts ago if I code it your way, but no warning if I use the code 2 posts ago. Essentially what happened is that when I type in 1, 2, or 3 the program automatically ends. I think it's my while function testing wrong.
|
|
|
Post by fwiss on Jan 29, 2011 12:28:30 GMT -5
Ooops, sorry DJ you were right, I did it wrong. I apologize. I just got confused sorry. Couldn't have done it without ya!
|
|