Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to use CString::Find() in VC++ 4.0

Posted on 1998-12-14
1
Medium Priority
?
384 Views
Last Modified: 2008-03-10
Could you give me an example of how the CString :: Find() works on a CString member?? The help included in the VC++ index is not very clear to me. Thanks!
Bruce
Quebec Canada
0
Comment
Question by:pigeonbr
1 Comment
 
LVL 8

Accepted Solution

by:
Answers2000 earned 200 total points
ID: 1180171
CString str = "abcdefbc" ;

int nIndex = str.Find( "bc" ) ; // find a string
// nIndex will 1 because the first occurrence of string bc in str is at position 1 (the first character in str counts as position 0 )
// similarly
CString str2 = "bc" ;
int nIndex2 = str.Find( str2 ) ;

int nIndex3 = str.Find( 'c' ) ; // find a character
// will find the c at position 2 (meaning nIndex3 becomes 2)

int nIndex4 = str.Find( "xyz" ) ; // not found
int nIndex5 = str.Find( 'n' ) ; // not found
// these return -1 for nIndex4 and nIndex5 meaning the item is not found



0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question