Results 1 to 4 of 4

Thread: Function search in a string

  1. #1
    Join Date
    Oct 2009
    Posts
    10

    Function search in a string

    I have created an algorithm that searches a string in another string, but it does not work.
    Code:
    char * ZString:: search (char * string)
     (
    	 int i = 0, j = 0; 
    	 bl ok = true;
    
    	 for (i = 0; i <m_long; i + +)
    	 (
    		 if (m_ch [i] == string [0])
    		 (
    			 for (int j = 1 j <length (str) & & ok; j + +)
    			 (
    				 if (m_ch [i + j]! = string [j])
    					 ok = false;
    
    				 if (m_ch [i + j]! = string [j] == j & & (length (string) - 1))
    					 return & m_ch [i];
    
    			 )
    
    			 ok = true;
    		 )
    	 )
    
    	 return NULL;
     )

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Function search in a string

    String to be searched for in the object. The entire content of str must be matched in some part of the string to be considered a match. The Filter function takes a string array and a string containing the search text. It returns a one-dimensional array containing all the elements that match the search text.

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Function search in a string

    I think the error must come from the line 15. You should write:

    if (m_ch [i + j] == string [j] == j & & (length (string) - 1))


    Otherwise be careful, because when you look at the character [i + j] you might leave the table. To avoid this you must write

    for (i = 0; i <(m_long - length (string)); i + +)

    for your first loop.

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Function search in a string

    You must take the first character of your search string in another string. imagined that character is to the number n. So the second you take the character and you compare year + 1, even if it is you did another test with the third character n + 2 and so on until you either \ 0. If you have returned your first character you find in a continuous chain, until you arrive at the end of your search string.

Similar Threads

  1. Quick search Function in Opera with different Search engines?
    By Oorja in forum Technology & Internet
    Replies: 2
    Last Post: 23-02-2012, 05:53 PM
  2. Return string from a function in C
    By Samarth in forum Software Development
    Replies: 3
    Last Post: 28-12-2009, 12:24 PM
  3. Search character in a string
    By Zool in forum Software Development
    Replies: 3
    Last Post: 14-12-2009, 02:45 PM
  4. How to use a loop function to reverse a counter string?
    By LostIt in forum Software Development
    Replies: 3
    Last Post: 08-08-2009, 07:54 PM
  5. Search a string in a textbox
    By GeforceUser in forum Software Development
    Replies: 4
    Last Post: 07-05-2009, 01:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,429,116.84395 seconds with 16 queries