syntax error

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2005
Posts: 91
Reputation: Jon182 is an unknown quantity at this point 
Solved Threads: 0
Jon182 Jon182 is offline Offline
Junior Poster in Training

syntax error

 
0
  #1
Feb 21st, 2006
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.

  1. char *ch=array;
  2. while((ch = strstr( ch, "jo ")) != 0)
  3.  
  4. if( ch == array '||isspace (*(ch-1)))
  5. {
  6. temp.count++;
  7. ch++;
  8.  
  9.  
  10. }
  11. else
  12. {
  13. break;
  14. }
  15.  
  16. }
  17.  
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: syntax error

 
0
  #2
Feb 21st, 2006
Use this.
  1. 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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 91
Reputation: Jon182 is an unknown quantity at this point 
Solved Threads: 0
Jon182 Jon182 is offline Offline
Junior Poster in Training

Re: syntax error

 
0
  #3
Feb 21st, 2006
Hi thanks for your reply the logic seems to be working alright for me. What do you think was wrong with it?

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: syntax error

 
0
  #4
Feb 21st, 2006
Nothing. I said that because I didnt know your requirements. If it meets your requirements then it is correct.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 91
Reputation: Jon182 is an unknown quantity at this point 
Solved Threads: 0
Jon182 Jon182 is offline Offline
Junior Poster in Training

Re: syntax error

 
0
  #5
Feb 21st, 2006
Originally Posted by WolfPack
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1277 | Replies: 4
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC