Difference between revisions of "Listing 8 4 CharArray"

From ArduinoInfo
Jump to: navigation, search
(Imported from text file)
 
m (Text replacement - "</div>" to "")
 
Line 26: Line 26:
 
  }
 
  }
 
  <span style="color: #00979C">void</span> <span style="color: #5E6D03">loop</span>() {}
 
  <span style="color: #00979C">void</span> <span style="color: #5E6D03">loop</span>() {}
 
 
 
</div>
 

Latest revision as of 16:51, 5 February 2019

/* Listing 8-4. Display character array.

  Purpose: Display a character array using array indexes
  
  Dr. Purdum, Nov 22, 2014
 */

void setup() {
  char greet[6];
  int i;

  Serial.begin(9600);

  greet[0] = 'H';      // Initialize the array with some characters
  greet[1] = 'e';      // the slow way...
  greet[2] = 'l';
  greet[3] = 'l';
  greet[4] = 'o';
  greet[5] = '\0';     // null termination character 

  for (i = 0; i < 5; i++) {
    Serial.print(greet[i]);
  }
}
void loop() {}