函式 isblank() 用於檢查傳遞的字元是否為空格。它基本上是一個空格字元,也考慮製表符(\t)。此函式在 C 語言的“ctype.h”標頭檔案中宣告,在 C++ 語言的“cctype”標頭檔案中宣告。以下是 C++ 語言中 isblank() 的語法:int isblank(int char);以下是在 C++ 語言中使用 isblank() 的示例:示例即時演示#include #include using namespace std; int main() { string s = "The space between words. "; int i = 0; int count = 0; while(s[i]) { ... 閱讀更多
malloc()函式 malloc() 用於分配請求大小的位元組,並返回指向分配記憶體第一個位元組的指標。如果失敗,則返回空指標。以下是 C++ 語言中 malloc() 的語法:pointer_name = (cast-type*) malloc(size);其中,pointer_name - 指標的任意名稱。cast-type - 您希望 malloc() 將分配的記憶體強制轉換為的資料型別。size - 以位元組為單位分配的記憶體大小。以下是在 C 語言中使用 malloc() 的示例:示例即時演示#include #include int main() { int n = 4, i, *p, s = 0; p = ... 閱讀更多
main() 函式的返回值顯示程式如何退出。程式的正常退出由零返回值表示。如果程式碼存在錯誤、故障等,則將由非零值終止。在 C++ 語言中,可以不帶返回值地離開 main() 函式。預設情況下,它將返回零。以下是 C 語言中 main() 函式的語法:int main() { …. return 0; }以下是在 C 語言中使用 main() 函式的示例:示例即時演示#include int main() { int a = 10; char b = 'S'; float c = ... 閱讀更多