Reference for Wiring version 0027+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Class

String

Name

compareTo()

Examples
void setup() 
{
  String str = String("CCCP");
  String str1 = String("CCCP");
  int p1 = str.compareTo(str1);
  Serial.begin(9600);
  Serial.println(p1, DEC); // Prints 0
}

void loop() 
{

}
Description Compares two strings lexicographically based on the value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence represented by the argument string. The result is a negative integer if this String object lexicographically precedes the argument string. The result is a positive integer if this String object lexicographically follows the argument string. The result is zero if the strings are equal.
Syntax
compareTo(str)
Parameters
str String: the substring to compare with
Returns int
Usage Application
Updated on September 16, 2010 11:34:09pm PDT

Creative Commons License