Simple IF problem
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
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
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
Check out my shadows page and send me some feedback
May 08, 2000 05:03 PM
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
B
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement