compare CString

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carl Forsman

    compare CString

    how to compare a CString?

    the following does not seem to work.

    CString id = PictureEntries[i].attribute("id" ).value();

    if (id.Compare("22 22") == 1){
    cout << id << endl;
    }

  • Ian Collins

    #2
    Re: compare CString

    Carl Forsman wrote:
    how to compare a CString?
    >
    Try a windows group, CString isn't standard C++.

    --
    Ian Collins

    Comment

    • Salt_Peter

      #3
      Re: compare CString

      On Nov 16, 10:14 pm, Carl Forsman <fatwallet...@y ahoo.comwrote:
      how to compare a CString?
      >
      the following does not seem to work.
      >
      CString id = PictureEntries[i].attribute("id" ).value();
      >
      if (id.Compare("22 22") == 1){
      cout << id << endl;
      }
      Whats a CString?

      As a hint: what is the difference between a null terminated sequence
      of characters and one that isn't null terminated? The point here is
      that if you don't know or aren't sure, use a little brain power:

      CString id("abcdef")
      if( id.Compare( CString("abcdef ") )
      {
      // do stuff
      }

      Comment

      • David Connet

        #4
        Re: compare CString

        Salt_Peter <pj_hern@yahoo. comwrote in news:f28eec71-822f-4894-9332-
        d7fb8dddf8ae@k2 4g2000pri.googl egroups.com:
        On Nov 16, 10:14 pm, Carl Forsman <fatwallet...@y ahoo.comwrote:
        >how to compare a CString?
        >>
        >the following does not seem to work.
        >>
        >CString id = PictureEntries[i].attribute("id" ).value();
        >>
        > if (id.Compare("22 22") == 1){
        > cout << id << endl;
        > }
        >
        Whats a CString?
        >
        As a hint: what is the difference between a null terminated sequence
        of characters and one that isn't null terminated? The point here is
        that if you don't know or aren't sure, use a little brain power:
        >
        CString id("abcdef")
        if( id.Compare( CString("abcdef ") )
        {
        // do stuff
        }
        Which is why you shouldn't ask CString questions here! The above is
        wrong.

        if (0 == id.Compare("abc def"))
        {
        // do stuff
        }

        or

        if (id == "abcdef")
        {
        }

        The OP also asked in an MS group and "learned" how to make the proper
        call. Though the term RTFM was missing in those posts.

        Dave Connet

        Comment

        Working...