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.

Name

new

Examples
char *speeds = new char[4];  // creates a new char array

void setup() { 
  speeds[0] = 'a';  // set elements of the array 
  speeds[1] = 'b';
  speeds[2] = 'c';

  // ...

  delete [] speeds;  // releases the memory allocated for the array, from now on the array can't be used
} 
 
void loop() {
  // ...
}
Description Creates a "new" object. The keyword new is typically used similarly to the applications in the above example. In this example, a new array of chars called "speeds" is created. Operators new and delete can only be used with simple datatypes: int, long or char.
Usage Application
Related delete
Updated on July 07, 2011 11:08:43pm PDT

Creative Commons License