0

hey guys, I am using the following code to count from a text file but I also want to check for ",jo " as well as "jo " I was trying to do it by using while((ch = strstr( ch, "jo ")) != 0) || while((ch = strstr( ch, ",jo ")) != 0) but this doesn't work I was just wondering how I could so this thanks.

char *ch=array;
while((ch = strstr( ch, "jo ")) != 0) 

	if( ch == array '||isspace (*(ch-1)))
		{
			temp.count++;
		      ch++;
													
			
	}
		else
                    {
                        break;
                     }

}
2
Contributors
4
Replies
5
Views
12 Years
Discussion Span
Last Post by Jon182
0

Use this.

while( ( (ch = strstr( ch, "jo ") ) != 0) ||( (ch = strstr( ch, ",jo ")) != 0 ))

Note:
I am not sure about the logic, that is your responsibility. But the syntax is okay.

0

Hi thanks for your reply the logic seems to be working alright for me. What do you think was wrong with it?

Thanks.

0

Nothing. I said that because I didnt know your requirements. If it meets your requirements then it is correct.

0

Nothing. I said that because I didnt know your requirements. If it meets your requirements then it is correct.

Thanks in the end I couldn't use the || even with the correct syntax and just has to use another while loop or for some reason the program would crash. Not sure why it was crashing though.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.