Framework (A-Z)

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

Class

String

Name

compareTo()

Examples
String str = String("CCCP");
String str1 = String("CCCP");
int p1 = str.compareTo(str1);
Serial.println(p1, DEC); // Prints 0
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 July 07, 2011 11:09:04pm PDT

Creative Commons License