public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: string comparison C++
@ 2002-03-23  7:32 Paolo Carlini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Carlini @ 2002-03-23  7:32 UTC (permalink / raw)
  To: beeezaur; +Cc: gcc-help

Hi Scott,

your code is correct and compiles just fine with any standard compliant C++ run
time library. On the other hand, that bundled with RedHat's gcc2.96-RH (/not/ an
official GNU release, by the way) does not implement the compare method you
need.

Definitely, I suggest installing gcc3.0.4.

Ciao, Paolo.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: string comparison C++
@ 2002-03-23  7:34 Paolo Carlini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Carlini @ 2002-03-23  7:34 UTC (permalink / raw)
  To: beezaur; +Cc: gcc-help

Hi Scott,

your code is correct and compiles just fine with any standard compliant C++ run
time library. On the other hand, that bundled with RedHat's gcc2.96-RH (/not/ an
official GNU release, by the way) does not implement the compare method you
need.

Definitely, I suggest installing gcc3.0.4.

Ciao, Paolo.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* string comparison C++
@ 2002-03-23  2:12 beezaur
  0 siblings, 0 replies; 3+ messages in thread
From: beezaur @ 2002-03-23  2:12 UTC (permalink / raw)
  To: gcc-help

I'm a novice C++ programmer and perhaps I'm making a mistake, but I 
can't seem to find it.

I am trying to compare STL type strings, say

string s1("hello")
string s2("goodbye")

with the compare function, ie

s1.compare(1,2,s2,1,2)

I am using code verbatim from both my text, Deitel & Deitel "How to 
Program C++ 3rd ed", and Josuttis' "The C++ Standard Library", yet g++ 
refuses to compile, saying "no matching function for call to..."

Has the syntax changed since my books were printed?  Should I install 
gcc 3.04?  Maybe I'm missing some obvious error?

I'm using Red Hat Linux 7.2 (an upgrade from 7.1) and gcc (g++) 2.96, 
which was on the RH 7.2 CD.

A small example of this problem is below:

#include <iostream>
using std::cout;
using std::endl;

#include <string>
using std::string;

int main()
{
    string s1("string1"), s2("string2");

    cout << "s1.compare(s2): " << s1.compare(s2) << endl;     // ok

    cout << "s1.compare(1,3,s2,1,3): " << s1.compare(1,3,s2,1,3)  << 
endl;    // not ok

    return 0;
}

Thank you for any help or direction you can offer.

Scott Pollock

-- 
A day without math is like a day without sunshine.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-03-23 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-23  7:32 string comparison C++ Paolo Carlini
  -- strict thread matches above, loose matches on Subject: below --
2002-03-23  7:34 Paolo Carlini
2002-03-23  2:12 beezaur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).