Description

Analyze if a char is punctuation (that is a comma, a semicolon, an exclamation mark and so on). Returns true if the input char is punctuation.

Syntax

Use the following function to evaluate a char variable:

isPunct(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 punctuation.

Example Code

char myChar = '!';  // try with 'a' for a non punctuation char

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

  if (isPunct(myChar)) {  // tests if myChar is a punctuation character
    Serial.println("The character is a punctuation");
  } else {
    Serial.println("The character is not a punctuation");
  }
}

void loop() {
}

See also