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

startsWith()

Examples
void setup() { 
  Serial.begin(9600); 
  String str1 = String("CCCP");
  String str2 = String("CC");
  // Tests to see if str1 starts with str2
  if (str1.startsWith(str2) == true) {
    // The string starts with so this line will print
    Serial.println("Starts with");  
  } 
  else {
    Serial.println("don't");
  }
} 

void loop() { 
  // Nothing for loop()
}
Description Tests if this string starts with the specified string. Returns true if the string starts with the specified string and false if not.
Syntax
startsWith(str)
startsWith(str, offset)
Parameters
str String: any valid character string
offset int: beginning at a specified index
Returns boolean
Usage Application
Updated on July 07, 2011 11:09:09pm PDT

Creative Commons License