Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #15162

Re: comparing two std::string variables

From nick_keighley_nospam@hotmail.com
Newsgroups comp.lang.c++
Subject Re: comparing two std::string variables
Date 2012-03-29 00:46 -0700
Organization http://groups.google.com
Message-ID <9416468.2253.1333007212926.JavaMail.geo-discussion-forums@ynmb12> (permalink)
References <df58aa78-c003-4a2a-8fb8-8d602ee51b3e@a5g2000vbl.googlegroups.com>

Show all headers | View raw


On Wednesday, March 28, 2012 11:25:36 PM UTC+1, Gus Gassmann wrote:

> I am trying to compare two std::string objects str1 and str2. Both
> strings are rather long (~70000 characters). The first one is read
> from a file, the second one is generated by a program. I am trying to
> establish that the two strings are equal. However, it turns out that
> the string read in from the file has additional white space in several
> places. (The white space does not concern me; I will declare the
> strings equal if the other characters match.)  In order to compare
> them it seems that I must compress them both.

not really. can't you just skip the spaces?

> What is the best way to
> do that? Do I have to copy each std::string to a char*, or is there a
> better way?

you know you can index std::string?

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

comparing two std::string variables Gus Gassmann <horand.gassmann@googlemail.com> - 2012-03-28 15:25 -0700
  Re: comparing two std::string variables Tomasz D <tdolbniak@gmail.com> - 2012-03-28 23:25 -0700
  Re: comparing two std::string variables Gus Gassmann <horand.gassmann@googlemail.com> - 2012-03-29 03:18 -0700
    Re: comparing two std::string variables "AnonMail2005@gmail.com" <anonmail2005@gmail.com> - 2012-03-29 10:33 -0700
    Re: comparing two std::string variables Timothy Madden <terminatorul@gmail.com> - 2012-04-09 13:02 -0700
  Re: comparing two std::string variables nick_keighley_nospam@hotmail.com - 2012-03-29 00:46 -0700

csiph-web