Solved

Question on string

Posted on 1998-11-05
6
190 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
[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
  • 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
Industry Leaders: 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!

 

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

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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 51
iSeries FTP Exit Program 8 174
maxBlock challenge 30 151
VBA "SendKeys" Syntax for Multiple Keystrokes 7 133
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

751 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