Solved

Question on string

Posted on 1998-11-05
6
173 Views
Last Modified: 2013-11-20
Hi there,

          Suppose there is a string,
"Brandon (living in USA)" My question is how can I compare with the string in bracket? My condition statement will look something like this....
if(str = "(living in USA)")
   usa = true;

For ur info. I'm using MSVC 5.0 and working on a win98 platform.

Any help offered is very much appreciated!!!
0
Comment
Question by:justinng
  • 4
6 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1324271
Look at the help for the strcmp* functions (or CString class if its a CString). One of these locate a substring in another string.

Cheers,

Raymond.
0
 

Author Comment

by:justinng
ID: 1324272
I've checked out the CString class but I'm still unable to identify the right function to use if I want to compare a substring with a string. Note that I'm comparing a CString and a string... so I dunno if I need to convert them to the same type.... please help!

Thanks!
0
 
LVL 23

Accepted Solution

by:
chensu earned 20 total points
ID: 1324273
If I understand your question correctly, you are comparing the substrings. You can use CString::Find to do so. For example,

CString str = _T("Brandon (living in USA)");

if (str.Find(_T("(living in USA)")) != ¨C1)
    usa = true;
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:justinng
ID: 1324274
what is the 2 dots on the left of C1 ??
0
 

Author Comment

by:justinng
ID: 1324275
What is C1 by the way?
0
 

Author Comment

by:justinng
ID: 1324276
Hey! Thanks... I got it!!! heheee....
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 54
Define unique primary key 9 92
conditional code and condition difference 9 82
sum67 challenge 35 97
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

813 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

15 Experts available now in Live!

Get 1:1 Help Now