如何在 Arduino 中使用 isGraph()?


isGraph() 函式與 Arduino 中的 isPrintable() 函式非常類似。唯一的區別是 isGraph() 僅在列印的字元具有一定內容時返回真。因此,空白會被 isGraph() 排除在外,但會被 isPrintable() 包含在內。所有具有內容的普通字元、數字、特殊字元透過 isGraph() 時都會返回真。

語法

語法如下 −

isGraph(myChar)

其中 myChar 是正在檢查的字元。一個簡單的問題。製表符和換行符是否會透過 isGraph() 返回真。

示例

用下面類似的簡單程式碼驗證你的答案 −

void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println();
   char myChar = '
';    if (isGraph(myChar)) {       Serial.println("myChar is printable with content");    } else {       Serial.println("myChar is NOT printable with content");    } } void loop() {    // put your main code here, to run repeatedly: }

更新於: 30-07-2021

228 次瀏覽

開啟你的 職業 生涯

完成課程並獲得認證

立即開始
廣告
© . All rights reserved.