Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Odd problem with an if statement

Author
Message
Timber Wolf
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location:
Posted: 5th Sep 2009 07:24 Edited at: 5th Sep 2009 07:29
I'm busy teaching myself C++ and thought what would be a better way than to do it with Dark GDK. Well I've run into an interesting problem.



The problem occurs with the satement if ( DrSt = 2 ). I have DrSt declared as an integer with the initial value 0 and there is no other mention of DrSt in the code. The problem is that as soon as I step into the designated coordinats, DrSt jumps to 2 despite the lack of a DrSt=2 statement. I have a dbText code printing DrSt's value so I can watch it happen. As such all the things that should happen only when DrSt=2 are happening. The best I can tell is that my program decided for this moment that the if statement is slang for 'do this'. Has anyone encountered a similar problem? Once again, I'm new to C++ so I won't be surprised if I'm just doing something stupid.

EDIT: Solved it quick. used = and not ==. Noobie me :-| Admin feel free to delete this.


Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 5th Sep 2009 07:28 Edited at: 5th Sep 2009 07:30
A single '=' is used for assignment ( int num = 5; )

You need to use double equal signs '=='.
They evaluate to a true/false condition, to be used in control structures. ( if, for, while, etc )

EDIT: Fixed accidental smileys

Your_Health = (My_Mood == HAPPY) ? 100 : NULL;
Timber Wolf
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location:
Posted: 5th Sep 2009 07:29
got ya, was just editing


Login to post a reply

Server time is: 2024-10-01 12:39:09
Your offset time is: 2024-10-01 12:39:09