<<< | Index | >>> |
|
#include <cassert> #include <string> using std::string; void main() { string s1 = "Hello world"; // Compare "Hello world" with "Fred": int result = s1.compare( "Fred" ); // Returns positive: H > F assert( result > 0 ); // Compare "world" with "zone": result = s1.compare( 6, string::npos, "zone" ); // Returns negative: w < z assert( result < 0 ); }
|
<<< | Index | >>> |