isWhitespace()

Descrição

Analisa se um caractere é um espaço em branco, isto é o próprio caractere de espaço (' '), formfeed ('\f'), nova linha ('\n'), retorno ('\r'), tab horizontal tab ('\t') e tab vertical ('\v')).

Retorna true se thisChar contém um espaço em branco.

Sintaxe

isWhitespace(thisChar)

Parâmetros

  • thisChar: variável. Tipos de dados permitidos: char

Retorna

true: se thisChar é um caractere de espaço em branco.

Código de Exemplo

char myChar; void setup() { Serial.begin(9600); myChar = ' '; Serial.print(myChar); Serial.print(": "); if (isWhitespace(myChar)) // testa se meuChar é um caractere de espaço em branco Serial.println("The character is a space or tab"); else Serial.println("The character is not a space or tab"); myChar = '\t'; Serial.print(myChar); Serial.print(": "); if (isWhitespace(myChar)) // testa se meuChar é um caractere de espaço em branco Serial.println("The character is a space or tab"); else Serial.println("The character is not a space or tab"); myChar = 'A'; Serial.print(myChar); Serial.print(": "); if (isWhitespace(myChar)) // testa se meuChar é um caractere de espaço em branco Serial.println("The character is a space or tab"); else Serial.println("The character is not a space or tab"); } void loop() {}

The result in Serial Monitor:

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
: The character is a space or tab : The character is a space or tab A: The character is not a space or tab
Ln 11, Col 1
Arduino Uno on COM15
2

Ver Também

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables .

※ OUR MESSAGES