Description

Analyze if a char is a space character. Returns true if the input char is a space or horizontal tab ('\t').

Syntax

Use the following function to evaluate a char variable:

isWhitespace(thisChar)

Parameters

The function admits the following parameter:

thisChar: char variable to evaluate. Allowed data types: char.

Returns

The function returns true if the evaluated input variable is a space character.

Example Code

char myChar = '\t';  // try with 'a' for a non space char

void setup() {
  Serial.begin(9600);

  if (isWhitespace(myChar)) {  // tests if myChar is a space character
    Serial.println("The character is a space or tab");
  } else {
    Serial.println("The character is not a space or tab");
  }
}

void loop() {
}

See also