C++ 程式設計/標頭檔案
外觀
< C++ 程式設計
這些標準標頭檔案定義了最初在 C 程式語言中定義的函式。它們使將 C 程式碼移植到 C++ 變得更加容易。
這些只是 C++ 標準標頭檔案 中的少數幾個。
#include <cctype> int isalnum(int c); int isalpha(int c); int iscntrl(int c); int isdigit(int c); int isgraph(int c); int islower(int c); int isspace(int c); int isprint(int c); int isupper(int c);
C++ 程式設計師幾乎從未使用過這些 cstring 函式,我們使用 字串類 來代替。
#include <cstring> size_t strlen(char* str); char* strcpy(char* dest, char* src); char* strncpy(char* dest, char* src, size_t length); int strcmp(const char* s1, const char* s2); int strncmp(const char* s1, const char* s2, size_t length); char* strtok(char* str, const char* delim); char* strchr(const char* str, int c); char* strstr(const char* str, const char* within);
#include <ctime> clock_t clock(void); double difftime(time_t t1, time_t t0); time_t mktime(struct tm *timeptr); time_t time(time_t *timer); char *asctime(struct tm *timeptr); char *ctime(const time_t *timer); struct tm *gmtime(const time_t *timer); struct tm *localtime(const time_t *timer); size_t strftime(char * s, size_t maxsize, const char * format, struct tm * timeptr); clock_t clock(void); double difftime(time_t t1, time_t t0); time_t mktime(struct tm *timeptr); time_t time(time_t *timer); char *asctime(struct tm *timeptr); char *ctime(const time_t *timer); struct tm *gmtime(const time_t *timer); struct tm *localtime(const time_t *timer); size_t strftime(char * s, size_t maxsize, const char * format, struct tm * timeptr);
這些 cmath 函式在許多物理模擬中被大量使用,例如逼真的電子遊戲、有限元分析等。
#include <cmath>
有關 標準 C 庫數學 或 C 程式設計 華夏公益教科書 進一步數學頁面 的更多詳細資訊,請參見該書部分。
此標頭檔案列出了所有 C++ 中使用的基本資料型別 的最大值和最小值。
#include <climits>
對應於 C 語言中的 "limits.h"。