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


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

Re: comparing two std::string variables

From Tomasz D <tdolbniak@gmail.com>
Newsgroups comp.lang.c++
Subject Re: comparing two std::string variables
Date 2012-03-28 23:25 -0700
Organization http://groups.google.com
Message-ID <22526991.1156.1333002301389.JavaMail.geo-discussion-forums@vbxy18> (permalink)
References <df58aa78-c003-4a2a-8fb8-8d602ee51b3e@a5g2000vbl.googlegroups.com>

Show all headers | View raw


If you already have the code that reads the contents of a file into a string you could consider comparing hashes of strings instead of strings themselves.

But if I were to solve such problem I think I would try doing it "sequentially": 

1. read in a couple of bytes
2. compare to the corresponding part of the generated string
3. stop the whole process if the compared parts are not equal
4. back to 1

This could save you some time and resources needed for reading in the whole file if the difference is found before the EOF.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next 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