Thread: syntax error

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    133

    syntax error

    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.

    Code:
    char *ch=array;
    while((ch = strstr( ch, "jo ")) != 0) 
    
    	if( ch == array '||isspace (*(ch-1)))
    		{
    			temp.count++;
    		      ch++;
    													
    			
    	}
    		else
                        {
                            break;
                         }
    
    }

  2. #2
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Code:
    char *ch=array;
    while((ch = strstr( ch, "jo ")) != 0) 
    
    	if( ch == array '||isspace (*(ch-1))) // what is this single quote for
    		{
    			temp.count++;
    		      ch++;
    													
    			
    	}
    		else
                        {
                            break;
                         }
    
    }
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    Code:
    if( myString.find(",jo") != string::npos || myString.find("jo") != string::npos)
        cout<<"found one of 'em"<<endl;

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Quote Originally Posted by 7stud
    Code:
    if( myString.find(",jo") != string::npos || myString.find("jo") != string::npos)
        cout<<"found one of 'em"<<endl;
    In other words, use a string object not a character pointer.
    Sent from my iPadŽ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM