Solved

Question on string

Posted on 1998-11-05
6
155 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

12 Experts available now in Live!

Get 1:1 Help Now