Re: conditional if..else
Re: conditional if..else
- Subject: Re: conditional if..else
- From: Tommy Nordgren <email@hidden>
- Date: Wed, 18 Jul 2007 13:03:22 +0200
On 17 jul 2007, at 20.00, Frank Murray wrote:
Hello,
This is a new post, and I am relatively new to the XCode IDE.
Listed below is a
snippet of code, using string (char) constants along with if...else
statements. The code
speaks for itself, but obviously does not work the intended way.
Meaning, no matter if you enter "Celcius" or "Fahrenheit", the
conditional always defaults
to "neither." I'm guessing the code if <some condition> == <some
string or char statement>
is not being equated or compiled properly, so any info is
appreciated. Thanks.
char scale[12];
..snip..
if (scale == "Celcius")
You are comparing the adresses instead of the content of the strings.
Use : if (strcmp(scale, "Celcius") == 0)
or code in C++ and use std::string instead of character arrays.
------------------------------------------------------
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden