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

toInt()

Examples
void setup() { 
  Serial.begin(9600); 
  String str1 = String("1547"); 
  int num = str1.toInt() + 3;
  
  Serial.println(num, DEC);  // prints 1550
}

void loop() { 

}
Description Converts a string to its numerical representation. For example, "123" will convert to 123.
Syntax
data.toInt()
Parameters
data String: the current string
Returns int: the numerical representation of the string
Usage Application
Updated on July 07, 2011 11:09:10pm PDT

Creative Commons License