Skip to content

Instantly share code, notes, and snippets.

@melvincabatuan
Last active January 8, 2021 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melvincabatuan/d95feb6390e534c9b01d01798130cf4f to your computer and use it in GitHub Desktop.
Save melvincabatuan/d95feb6390e534c9b01d01798130cf4f to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
int main ()
{
std::string str1 ("The");
std::string str2 ("the");
std::string str3 ("fox");
if (str1.compare(str2) != 0)
std::cout << str1 << " is not " << str2 << std::endl; // "The" is not "the"
std::cout << str1.compare(str2) << std::endl; // -1 "The" comes before "the"
std::cout << str2.compare(str3) << std::endl; // +1 "the" comes after or greater than "fox"
std::cout << str3.compare(str2) << std::endl; // -1 "fox" comes before "the"
return 0;
}
/*
English-language ASCII sequence:
blank ! " # $ % & ' ( ) * + , - . /0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z[ \] ˆ_
a b c d e f g h i j k l m n o p q r s t u v w x y z { } ~
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment