C语言标准库函数大全(ctype、time 、stdio、stdlib、math、string)
生活随笔
收集整理的這篇文章主要介紹了
C语言标准库函数大全(ctype、time 、stdio、stdlib、math、string)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
文章目錄
- C語言函數(shù)庫:
- 一. <ctype.h>
- 二. <math.h>
- 三. <stdio.h>
- 四. <stdlib.h>
- 五. <time.h>
- 六. <string.h>
- 文檔資料
C語言函數(shù)庫:
C語言的常用的標(biāo)準(zhǔn)頭文件有 :
<ctype.h> ? <time.h> ? <stdio.h>
<stdlib.h> ? <math.h> ? <string.h>
一. <ctype.h>
| 1 | int iscntrl(int c) | 判斷字符c是否為控制字符。 |
| 2 | int isalnum(int c) | 判斷字符c是否為字母或數(shù)字 |
| 3 | int isalpha(int c) | 判斷字符c是否為英文字母 |
| 4 | int isascii(int c) | 判斷字符c是否為ascii碼 |
| 5 | int isblank(int c) | 判斷字符c是否為TAB或空格 |
| 6 | int isdigit(int c) | 判斷字符c是否為數(shù)字 |
| 7 | int isgraph(int c) | 判斷字符c是否為除空格外的可打印字符 |
| 8 | int islower(int c) | 判斷字符c是否為小寫英文字母 |
| 9 | int isprint(int c) | 判斷字符c是否為可打印字符(含空格) |
| 10 | int ispunct(int c) | 判斷字符c是否為標(biāo)點符號 |
| 11 | int isspace(int c) | 判斷字符c是否為空白符 |
| 12 | int isupper(int c) | 判斷字符c是否為大寫英文字母 |
| 13 | int isxdigit(int c) | 判斷字符c是否為十六進(jìn)制數(shù)字 |
| 14 | int toascii(int c) | 將字符c轉(zhuǎn)換為ascii碼 |
| 15 | int tolower(int c) | 將字符c轉(zhuǎn)換為小寫英文字母 |
| 16 | int toupper(int c); | 將字符c轉(zhuǎn)換為大寫英文字母 |
二. <math.h>
| 1 | float fabs(float x) | 求浮點數(shù)x的絕對值 |
| 2 | int abs(int x) | 求整數(shù)x的絕對值 |
| 3 | float acos(float x) | 求x(弧度表示)的反余弦值 |
| 4 | float asin(float x) | 求x(弧度表示)的反正弦值 |
| 5 | float atan(float x) | 求x(弧度表示)的反正切值 |
| 6 | float atan2(float y, float x) | 求y/x(弧度表示)的反正切值 |
| 7 | float ceil(float x) | 求不小于x的最小整數(shù) |
| 8 | float cos(float x) | 求x(弧度表示)的余弦值 |
| 9 | float cosh(float x) | 求x的雙曲余弦值 |
| 10 | float exp(float x) | 求e的x次冪 |
| 11 | float floor(float x) | 求不大于x的最大整數(shù) |
| 12 | float fmod(float x, float y) | 計算x/y的余數(shù) |
| 13 | float frexp(float x, int *exp) | 把浮點數(shù)x分解成尾數(shù)和指數(shù) |
| 14 | float ldexp(float x, int exp) | 返回x*2^exp的值 |
| 15 | float modf(float num, float *i) | 將浮點數(shù)num分解成整數(shù)部分和小數(shù)部分 |
| 16 | float hypot(float x, float y) | 對于給定的直角三角形的兩個直角邊,求其斜邊的長度 |
| 17 | float log(float x) | 計算x的自然對數(shù) |
| 18 | float log10(float x) | 計算x的常用對數(shù) |
| 19 | float pow(float x, float y) | 計算x的y次冪 |
| 20 | float pow10(float x) | 計算10的x次冪 |
| 21 | float sin(float x) | 計算x(弧度表示)的正弦值 |
| 22 | float sinh(float x) | 計算x(弧度表示)的雙曲正弦值 |
| 23 | float sqrt(float x) | 計算x的平方根 |
| 24 | float tan(float x); | 計算x(弧度表示)的正切值 |
| 25 | float tanh(float x) | 求x的雙曲正切值 |
三. <stdio.h>
| 1 | int printf(char *format...) | 產(chǎn)生格式化輸出的函數(shù) |
| 2 | int getchar(void) | 從鍵盤上讀取一個鍵,并返回該鍵的鍵值 |
| 3 | int putchar(char c) | 在屏幕上顯示字符c |
| 4 | FILE *fopen(char *filename, char *type) | 打開一個文件 |
| 5 | FILE *freopen(char *filename, char *type,FILE *fp) | 打開一個文件,并將該文件關(guān)聯(lián)到fp指定的流 |
| 6 | int fflush(FILE *stream) | 清除一個流 |
| 7 | int fclose(FILE *stream) | 關(guān)閉一個文件 |
| 8 | int remove(char *filename) | 刪除一個文件 |
| 9 | int rename(char *oldname, char *newname) | 重命名文件 |
| 10 | FILE *tmpfile(void) | 以二進(jìn)制方式打開暫存文件 |
| 11 | char *tmpnam(char *sptr) | 創(chuàng)建一個唯一的文件名 |
| 12 | int setvbuf(FILE *stream, char *buf, int type, unsigned size) | 把緩沖區(qū)與流相關(guān) |
| 13 | int fprintf(FILE *stream, char *format[, argument,...]) | 傳送格式化輸出到一個流中 |
| 14 | int scanf(char *format[,argument,...]) | 執(zhí)行格式化輸入 |
| 15 | int fscanf(FILE *stream, char *format[,argument...]) | 從一個流中執(zhí)行格式化輸入 |
| 16 | int fgetc(FILE *stream) | 從流中讀取字符 |
| 17 | char *fgets(char *string, int n, FILE *stream) | 從流中讀取一字符串 |
| 18 | int fputc(int ch, FILE *stream) | 送一個字符到一個流中 |
| 19 | int fputs(char *string, FILE *stream) | 送一個字符到一個流中 |
| 20 | int getc(FILE *stream) | 從流中取字符 |
| 21 | int getchar(void) | 從 stdin 流中讀字符 |
| 22 | char *gets(char *string) | 從流中取一字符串 |
| 23 | int putchar(int ch) | 在 stdout 上輸出字符 |
| 24 | int puts(char *string) | 送一字符串到流中 |
| 25 | int ungetc(char c, FILE *stream) | 把一個字符退回到輸入流中 |
| 26 | int fread(void *ptr, int size, int nitems, FILE *stream) | 從一個流中讀數(shù)據(jù) |
| 27 | int fwrite(void *ptr, int size, int nitems, FILE *stream) | 寫內(nèi)容到流中 int fseek |
| 28 | (FILE *stream, long offset, int fromwhere) | 重定位流上的文件指針 |
| 29 | long ftell(FILE *stream) | 返回當(dāng)前文件指針 |
| 30 | int rewind(FILE *stream) | 將文件指針重新指向一個流的開頭 |
| 31 | int fgetpos(FILE *stream) | 取得當(dāng)前文件的句柄 |
| 32 | int fsetpos(FILE *stream, const fpos_t *pos) | 定位流上的文件指針 |
| 33 | void clearerr(FILE *stream) | 復(fù)位錯誤標(biāo)志 |
| 34 | int feof(FILE *stream) | 檢測流上的文件結(jié)束符 |
| 35 | int ferror(FILE *stream) | 檢測流上的錯誤 |
| 36 | void perror(char *string) | 系統(tǒng)錯誤信息 |
四. <stdlib.h>
| 1 | char *itoa(int i) | 把整數(shù)i轉(zhuǎn)換成字符串 |
| 2 | void exit(int retval) | 結(jié)束程序 |
| 3 | double atof(const char *s) | 將字符串s轉(zhuǎn)換為double類型 |
| 4 | int atoi(const char *s) | 將字符串s轉(zhuǎn)換為int類型 |
| 5 | long atol(const char *s) | 將字符串s轉(zhuǎn)換為long類型 |
| 6 | double strtod (const char*s,char **endp) | 將字符串s前綴轉(zhuǎn)換為double型 |
| 7 | long strtol(const char*s,char **endp,int base) | 將字符串s前綴轉(zhuǎn)換為long型 |
| 8 | unsinged long strtol(const char*s,char **endp,int base) | 將字符串s前綴轉(zhuǎn)換為 unsinged long型 |
| 9 | int rand(void) | 產(chǎn)生一個0~RAND_MAX之間的偽隨機(jī)數(shù) |
| 10 | void srand(unsigned int seed) | 初始化隨機(jī)數(shù)發(fā)生器 |
| 11 | void *calloc(size_t nelem, size_t elsize) | 分配主存儲器 |
| 12 | void *malloc(unsigned size) | 內(nèi)存分配函數(shù) |
| 13 | void *realloc(void *ptr, unsigned newsize) | 重新分配主存 |
| 14 | void free(void *ptr) | 釋放已分配的塊 |
| 15 | void abort(void) | 異常終止一個進(jìn)程 |
| 16 | void exit(int status) | 終止應(yīng)用程序 |
| 17 | int atexit(atexit_t func) | 注冊終止函數(shù) |
| 18 | char *getenv(char *envvar) | 從環(huán)境中取字符串 |
| 19 | void *bsearch(const void *key, const void *base, size_t *nelem, size_t width, int(*fcmp)(const void *, const *)) | 二分法搜索函數(shù) |
| 20 | void qsort(void *base, int nelem, int width, int (*fcmp)()) | 使用快速排序例程進(jìn)行排序 |
| 21 | int abs(int i) | 求整數(shù)的絕對值 |
| 22 | long labs(long n) | 取長整型絕對值 |
| 23 | div_t div(int number, int denom) | 將兩個整數(shù)相除 , 返回商和余數(shù) |
| 24 | ldiv_t ldiv(long lnumer, long ldenom) | 兩個長整型數(shù)相除 , 返回商和余數(shù) |
五. <time.h>
| 1 | clock_t clock(void) | 確定處理器時間函數(shù) |
| 2 | time_t time(time_t *tp) | 返回當(dāng)前日歷時間 |
| 3 | double difftime(time_t time2, time_t time1) | 計算兩個時刻之間的時間差 |
| 4 | time_t mktime(struct tm *tp) | 將分段時間值轉(zhuǎn)換為日歷時間值 |
| 5 | char *asctime(const struct tm *tblock) | 轉(zhuǎn)換日期和時間為ASCII碼 |
| 6 | char *ctime(const time_t *time) | 把日期和時間轉(zhuǎn)換為字符串 |
| 7 | struct tm *gmtime(const time_t *timer) | 把日期和時間轉(zhuǎn)換為格林尼治標(biāo)準(zhǔn)時間 |
| 8 | struct tm *localtime(const time_t *timer) | 把日期和時間轉(zhuǎn)變?yōu)榻Y(jié)構(gòu) |
| 9 | size_t strftime(char *s,size_t smax,const char *fmt, const struct tm *tp) | 根據(jù) fmt 的格式 要求將 *tp中的日期與時間轉(zhuǎn)換為指定格式 |
六. <string.h>
| 1 | int bcmp(const void *s1, const void *s2, int n) | 比較字符串s1和s2的前n個字節(jié)是否相等 |
| 2 | void bcopy(const void *src, void *dest, int n) | 將字符串src的前n個字節(jié)復(fù)制到dest中 |
| 3 | void bzero(void *s, int n) | 置字節(jié)字符串s的前n個字節(jié)為零 |
| 4 | void *memccpy(void *dest, void *src, unsigned char ch, unsigned int count) | 由src所指內(nèi)存區(qū)域復(fù)制不多于count個字節(jié)到dest所指內(nèi)存區(qū)域,如果遇到字符ch則停止復(fù)制 |
| 5 | void *memcpy(void *dest, void *src, unsigned int count) | 由src所指內(nèi)存區(qū)域復(fù)制count個字節(jié)到dest所指內(nèi)存區(qū)域 |
| 6 | void *memchr(void *buf, char ch, unsigned count) | 從buf所指內(nèi)存區(qū)域的前count個字節(jié)查找字符ch |
| 7 | int memcmp(void *buf1, void *buf2, unsigned int count) | 比較內(nèi)存區(qū)域buf1和buf2的前count個字節(jié) |
| 8 | int memicmp(void *buf1, void *buf2, unsigned int count) | 比較內(nèi)存區(qū)域buf1和buf2的前count個字節(jié)但不區(qū)分字母的大小寫 |
| 9 | void *memmove(void *dest, const void *src, unsigned int count) | 由src所指內(nèi)存區(qū)域復(fù)制count個字節(jié)到dest所指內(nèi)存區(qū)域 |
| 10 | void *memset(void *buffer, int c, int count) | 把buffer所指內(nèi)存區(qū)域的前count個字節(jié)設(shè)置成字符c |
| 11 | void setmem(void *buf, unsigned int count, char ch) | 把buf所指內(nèi)存區(qū)域前count個字節(jié)設(shè)置成字符ch |
| 12 | void movmem(void *src, void *dest, unsigned int count) | 由src所指內(nèi)存區(qū)域復(fù)制count個字節(jié)到dest所指內(nèi)存區(qū)域 |
| 13 | char *stpcpy(char *dest,char *src) | 把src所指由NULL結(jié)束的字符串復(fù)制到dest所指的數(shù)組中 |
| 14 | char *strcpy(char *dest,char *src) | 把src所指由NULL結(jié)束的字符串復(fù)制到dest所指的數(shù)組中 |
| 15 | char *strcat(char *dest,char *src) | 把src所指字符串添加到dest結(jié)尾處(覆蓋dest結(jié)尾處的’\0’)并添加’\0’ |
| 16 | char *strchr(char *s,char c) | 查找字符串s中首次出現(xiàn)字符c的位置 |
| 17 | int strcmp(char *s1,char * s2) | 比較字符串s1和s2 |
| 18 | int stricmp(char *s1,char * s2) | 比較字符串s1和s2,但不區(qū)分字母的大小寫 |
| 19 | int stricmp(char *s1,char * s2) | 比較字符串s1和s2,但不區(qū)分字母的大小寫 |
| 20 | int strcspn(char *s1,char *s2) | 在字符串s1中搜尋s2中所出現(xiàn)的字符 |
| 21 | char *strdup(char *s) | 復(fù)制字符串s |
| 22 | int strlen(char *s) | 計算字符串s的長度 |
| 23 | char *strlwr(char *s) | 將字符串s轉(zhuǎn)換為小寫形式 |
| 24 | char *strupr(char *s) | 將字符串s轉(zhuǎn)換為大寫形式 |
| 25 | char *strncat(char *dest,char *src,int n) | 把src所指字符串的前n個字符添加到dest結(jié)尾處(覆蓋dest結(jié)尾處的’\0’)并添加’\0’ |
| 26 | int strcmp(char *s1,char * s2,int n) | 比較字符串s1和s2的前n個字符 |
| 27 | int strnicmp(char *s1,char * s2,int n) | 比較字符串s1和s2的前n個字符但不區(qū)分大小寫 |
| 28 | char *strncpy(char *dest, char *src, int n) | 把src所指由NULL結(jié)束的字符串的前n個字節(jié)復(fù)制到dest所指的數(shù)組中 |
| 29 | char *strpbrk(char *s1, char *s2) | 在字符串s1中尋找字符串s2中任何一個字符相匹配的第一個字符的位置,空字符NULL不包括在內(nèi) |
| 30 | char *strrev(char *s) | 把字符串s的所有字符的順序顛倒過來(不包括空字符NULL) |
| 31 | char *strset(char *s, char c) | 把字符串s中的所有字符都設(shè)置成字符c |
| 32 | char *strstr(char *haystack, char *needle) | 從字符串haystack中尋找needle第一次出現(xiàn)的位置(不比較結(jié)束符NULL) |
| 33 | char *strtok(char *s, char *delim) | 分解字符串為一組標(biāo)記串。s為要分解的字符串,delim為分隔符字符串 |
| 34 | int strnicmp(char *s1,char * s2,int n) | 比較字符串s1和s2的前n個字符但不區(qū)分大小寫 |
文檔資料
上面只是簡單的介紹函數(shù)原型和功能,如果想對函數(shù)進(jìn)一步了解可以下載以下文檔 (內(nèi)含詳解與實例):
1. C語言標(biāo)準(zhǔn)函數(shù)庫速查手冊.chm
2. C語言標(biāo)準(zhǔn)函數(shù)庫詳解.pdf
總結(jié)
以上是生活随笔為你收集整理的C语言标准库函数大全(ctype、time 、stdio、stdlib、math、string)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 计算机课程设计Servlet网上订餐系统
- 下一篇: VC6 CImage 加载jpg png