Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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. …
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…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

734 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