Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jLeslie

Simple IF problem

This topic is 6919 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can anyone tell me how to get these if statements to work? FILE *myfile = fopen(strFileName, "r"); char Chunk_Name[80]; while(fscanf(myfile, "%s" , Chunk_Name)) { if (Chunk_Name == "Bone") LoadBone(); if (Chunk_Name == "Chan") LoadChannel(); if (Chunk_Name == "Join") LoadJoint(); if (Chunk_Name == "PolH") LoadPolyhedron(); } Thanks

Share this post


Link to post
Share on other sites
Advertisement
why not use a switch statement?

or bung some elses in there
if (Chunk_Name == "Bone")
LoadBone();
else if (Chunk_Name == "Chan")
LoadChannel();
else if (Chunk_Name == "Join")
LoadJoint();
else if (Chunk_Name == "PolH")
LoadPolyhedron();


then they are all part of one statement...
maybe...

Check out my shadows page
and send me some feedback

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Dont try to use == with char* it will only give you grief, as you are experiencing now - use strcmp() to compare two strings for equality. When you do == with two char* the compiler will actually check the pointers to the first characters in the strings for equality not the actual value of the strings

B

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!