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 = ... 閱讀更多
modf() 函式用於將傳遞的引數拆分為整數和小數部分。它在“math.h”標頭檔案中宣告,用於數學計算。它返回傳遞引數的小數部分。以下是 C 語言中 modf() 的語法:double modf(double value, double *integral_pointer);其中,value - 將拆分為整數和小數部分的值。integral_pointer - 在拆分後指向引數的整數部分。以下是在 C 語言中使用 modf() 的示例:示例即時演示#include #include int main () { double val, x, res; val = 28.856; res = modf(val, &x); printf("Integral part of val ... 閱讀更多