Solved

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

Posted on 1998-12-14
1
348 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now