hello, i seem to be having a problem with my if statement for my basic program. I have a while loop that goes through a file and assigns certain values to a string str. The while loop works and correctly assigns the values to str however when i run my if styatements to filter out certain criteria, all statements get printed out even if it only find 1 match for some reason. Ive checked my if statement structure and it looks right to me, could anyone offer suggestions?
Code:
string str;
while ()
{
//loop through a file assigning values to 'str'
}
printf("%s", str); // test print which shows while loop works
if(strcmp ("dog", str) == 1)
{
printf("dog has found \n");
memset(str, 0, sizeof(str));
}
else if (strcmp ("cat", str) == 1)
{
printf("cat has found ");
memset(str, 0, sizeof(str));
}
else
{
printf("tortose");
memset(str, 0, sizeof(str));
}
thanks