944,161 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1443
  • C RSS
Feb 21st, 2006
0

syntax error

Expand Post »
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.  
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Jon182 is offline Offline
91 posts
since Jul 2005
Feb 21st, 2006
0

Re: syntax error

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.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Feb 21st, 2006
0

Re: syntax error

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

Thanks.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Jon182 is offline Offline
91 posts
since Jul 2005
Feb 21st, 2006
0

Re: syntax error

Nothing. I said that because I didnt know your requirements. If it meets your requirements then it is correct.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Feb 21st, 2006
0

Re: syntax error

Quote 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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Jon182 is offline Offline
91 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: How to input password in C
Next Thread in C Forum Timeline: quick sort question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC