Solved

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

Posted on 1998-12-14
1
363 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 50 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

828 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