Finding a substring inside a CString 
Author Message
 Finding a substring inside a CString

Quote:
-----Original Message-----

Hi,
        I'm using VC++6.0 and have declared a CString object.  I need to search
for a substring inside the string and have been trying to use the Find() function
to do it.  The only success I have found though is if the substring and the
string
are the exact same (same number of characters, same string).  I will paste the
code below that I am using.  Am I doing something wrong or just expecting
different results?

for(i=0;i<count;i++) //loop through array looking for alert
{
        str = list[i].alert_name;
        found = str.Find(alert.alert_name);
        if (found != -1)
        {
                MessageBox("Match Found!");
        }
}

looks OK to me, but I usually use stl instead of MFC.
you may want to try stl::string, that definetly works, is standard C++ and IMHO
more powerfull.

Claus

Thanks,
        Scott

.



Wed, 03 Sep 2003 00:04:42 GMT  
 Finding a substring inside a CString
Hi,
        I'm using VC++6.0 and have declared a CString object.  I need to search
for a substring inside the string and have been trying to use the Find() function
to do it.  The only success I have found though is if the substring and the string
are the exact same (same number of characters, same string).  I will paste the
code below that I am using.  Am I doing something wrong or just expecting
different results?

for(i=0;i<count;i++) //loop through array looking for alert
{
        str = list[i].alert_name;
        found = str.Find(alert.alert_name);
        if (found != -1)
        {
                MessageBox("Match Found!");
        }

Quote:
}

Thanks,
        Scott


Tue, 02 Sep 2003 23:32:41 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. CString Objects & subString :: MFC

2. Copy substring of CString?

3. strstr or strspn for finding a substring

4. Finding occurance of a substring in a string in C#

5. find tab using CString.Find

6. Initializing CString inside structure

7. Finding contents of TOC inside a library file

8. Finding DLL's inside EXE's

9. How to find name of the subclass inside the baseclass

10. API for finding a character inside a string????

11. Finding CD Inside Visual C++ 4 edition

12. How to find out if a point is inside a rotated graphics path

 

 
Powered by phpBB® Forum Software