Solved

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

Posted on 1998-12-14
1
366 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.

732 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