Description

Analyze if a char is a white-space character. Returns true if the input char is a space, form feed ('\f'), newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), or vertical tab ('\v').

Syntax

Use the following function to evaluate a char variable:

isSpace(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 white-space character.

Example Code

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

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

  if (isSpace(myChar)) {  // tests if myChar is a white-space character
    Serial.println("The character is white-space");
  } else {
    Serial.println("The character is not white-space");
  }
}

void loop() {
}

See also