Stuck on a Problem because I don't understand

More
12 May 2015 18:57 #1 by arholly
I was wondering if you might be able to help me with something. I've been plugging along on my code and making good progress but I'm stuck on something.

This is the code:
// OLC_CONFIG(d)->play.campaign == CAMPAIGN_FORGOTTEN_REALMS ? "Forgotten Realms" : "Dragonlance: Age of Legends",
OLC_CONFIG(d)->play.campaign == CampaignWorld[CONFIG_CAMPAIGN],    //<----Line 830
The above shows the old and the new code (code I want to use). I've used the CampaignWorld code elsewhere and I know it works, but when I go to compile it, it's giving me this error message:
cedit.c:830: warning: comparison between pointer and integer
cedit.c:840: warning: format â%sâ expects type âchar *â, but argument 24 has type âintâ

This is CampaignWorld:
const char *CampaignWorld[] =
{
  "Unknown - Alert Admin",
  "Faerun",
  "Krynn",
  "Golarion"
};

What is going wrong and how can I fix it? Any help you can provide would be great.

Please Log in or Create an account to join the conversation.

More
13 May 2015 02:49 #2 by plamzi
What you're seeing is the syntax [condition] ? [if true] : [if false]. The original statement means, "if campaign matches exactly the constant / macro, return static string "Forgotten Realms", otherwise return "Dragonlance", etc.

When you remove the stuff after ?, you can't keep the condition / comparison (==). If you are passing the result to a string building function, then I suspect what you need there is simply:
CampaignWorld[CONFIG_CAMPAIGN],

Please Log in or Create an account to join the conversation.

More
13 May 2015 12:02 #3 by arholly
Thanks. I did get it figured out.

Please Log in or Create an account to join the conversation.