Solved

How to compare CString with text ?

Posted on 2000-04-16
2
185 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
[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
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

 Database Backup and Recovery Best Practices

Join Percona’s, Architect, Manjot Singh as he presents Database Backup and Recovery Best Practices (with a Focus on MySQL) on Thursday, July 27, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7). In the case of a failure, do you know how long it will take to restore your database?

Question has a verified solution.

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

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: 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.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

624 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