Solved

How to compare CString with text ?

Posted on 2000-04-16
2
179 Views
Last Modified: 2013-11-20
hi,
 HOW do I compare a CString variable with a constant text say "HELLO".
The code is

CString& string =(CString) "text";
      if (ar.IsStoring())
      {
            // TODO: add storing code here
      }
      else
      {

            const CFile* fp = ar.GetFile();

            
        int      boolean = 1;

            while(boolean != NULL)
            
            {  
                 boolean = ar.ReadString(string);
                   if string == "HLAI"
                         a =1;
             else if string == "STIM"
                         b = 1;
                    
            else if string == "SI"
                        c = 1 ;
                        
0
Comment
Question by:mkjoshi
2 Comments
 
LVL 4

Accepted Solution

by:
inpras earned 30 total points
ID: 2720344
CString str;
str = "Some Text";

if (str.Find("HALLO") != -1)
{
//Hallo is present
}
else
{
//Hallo is not present
}

Use to upper or to lower for case insensitive
Hope this helps
inpras
0
 

Author Comment

by:mkjoshi
ID: 2721563
Adjusted points from 20 to 30
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add content to output file 4 62
notReplace  challenge 53 116
ShiftLeft challenge 21 76
Is there a simple front-end menu system. 9 70
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 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

23 Experts available now in Live!

Get 1:1 Help Now