• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: conditional if..else
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >conditional if..else (From: Frank Murray <email@hidden>)

  • Prev by Date: Warning: warning weak symbol references not set in output with…
  • Next by Date: Re: Inline functions get debugger confused about source files
  • Previous by thread: Re: conditional if..else
  • Next by thread: Re: conditional if..else
  • Index(es):
    • Date
    • Thread