日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

C语言_函数【转】

發布時間:2023/12/18 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C语言_函数【转】 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

引用地址:http://baike.baidu.com/link?url=U9h6MccLYX2w5uyVOqIFd3eps5gR2FZA10jYRLRnc66Ff_F5ZrmXGKA12DT-_2xfzjl8MXCa-BBJDrj1x3cgm_

1分類函數

2數學函數

3目錄函數

4進程函數

5診斷函數

6接口子程序

7操作函數

8時間日期函數

分類函數

所在函數庫為【ctype.h】

int isalpha(int ch) ?若ch是字母('A'-'Z','a'-'z')返回非0值,否則返回0

int isalnum(int ch) 若ch是字母('A'-'Z','a'-'z')或數字('0'-'9')

返回非0值,否則返回0

int?isascii(int ch) ?若ch是字符(ASCII碼中的0-127)返回非0值,否則返回0

int?iscntrl(int ch) ?若ch是作廢字符(0x7F)或普通控制字符(0x00-0x1F)

返回非0值,否則返回0

int isdigit(int ch) ?若ch是數字('0'-'9')返回非0值,否則返回0

int isgraph(int ch) ?若ch是可打印字符(不含空格)(0x21-0x7E)返回非0值,否則返回0

int islower(int ch) ?若ch是小寫字母('a'-'z')返回非0值,否則返回0

int isprint(int ch) ?若ch是可打印字符(含空格)(0x20-0x7E)返回非0值,否則返回0

int?ispunct(int ch) ?若ch是標點字符(0x00-0x1F)返回非0值,否則返回0

int isspace(int ch) ?若ch是空格(' '),水平制表符('\t'),回車符('\r'),

走紙換行('\f'),垂直制表符('\v'),換行符('\n')

返回非0值,否則返回0

int?isupper(int ch) ?若ch是大寫字母('A'-'Z')返回非0值,否則返回0

int?isxdigit(int ch) 若ch是16進制數('0'-'9','A'-'F','a'-'f')返回非0值,

否則返回0

int tolower(int ch) ?若ch是大寫字母('A'-'Z')返回相應的小寫字母('a'-'z')

int?toupper(int ch) ?若ch是小寫字母('a'-'z')返回相應的大寫字母('A'-'Z')

數學函數

所在函數庫為math.hstdio.hstring.hfloat.h

int ? abs(int i) ? ? ? ? ?返回整型參數i的絕對值

double cabs(struct complex znum) ? 返回復數znum的絕對值

double fabs(double x) ? ? ? ? 返回雙精度參數x的絕對值

long ?labs(long n) ? ? ? ? ?返回長整型參數n的絕對值

double ?exp(double x) ? ? ? ? 返回指數函數ex的值

double?frexp(double value,int *eptr) ?返回value=x*2n中x的值,n存貯在eptr中

double?ldexp(double value,int exp); ?返回value*2exp的值

double ?log(double x) ? ? ? ? 返回logex的值

double log10(double x) ? ? ? ? 返回log10x的值

double ?pow(double x,double y) ? ?返回xy的值

double?pow10(int p) ? ? ? ? ?返回10p的值

double sqrt(double x) ? ? ? ? 返回+√x的值

double acos(double x) ? ? ? ? 返回x的反余弦cos-1(x)值,x為弧度

double asin(double x) ? ? ? ? 返回x的反正弦sin-1(x)值,x為弧度

double atan(double x) ? ? ? ? 返回x的反正切tan-1(x)值,x為弧度

double atan2(double y,double x) ? ?返回y/x的反正切tan-1(x)值,y的x為弧度

double ?cos(double x) ? ? ? ? 返回x的余弦cos(x)值,x為弧度

double ?sin(double x) ? ? ? ? 返回x的正弦sin(x)值,x為弧度

double ?tan(double x) ? ? ? ? 返回x的正切tan(x)值,x為弧度

double cosh(double x) ? ? ? ? 返回x的雙曲余弦cosh(x)值,x為弧度

double sinh(double x) ? ? ? ? 返回x的雙曲正弦sinh(x)值,x為弧度

double tanh(double x) ? ? ? ? 返回x的雙曲正切tanh(x)值,x為弧度

double hypot(double x,double y) ? ?返回直角三角形斜邊的長度(z),

x和y為直角邊的長度,z2=x2+y2

double ceil(double x) ? ? ? ? 返回不小于x的最小整數

double floor(double x) ? ? ? ? 返回不大于x的最大整數

void ?srand(unsigned seed) ? ? ?初始化隨機數發生器

int ? rand() ? ? ? ? ? ? 產生一個隨機數并返回這個數

double poly(double x,int n,double c[])從參數產生一個多項式

double modf(double value,double *iptr)將雙精度數value分解成尾數和階

double fmod(double x,double y) ? ?返回x/y的余數

double?frexp(double value,int *eptr) ?將雙精度數value分成尾數和階

double atof(char *nptr) ? ? ? ?將字符串nptr轉換成浮點數并返回這個浮點數

double atoi(char *nptr) ? ? ? ?將字符串nptr轉換成整數并返回這個整數

double atol(char *nptr) ? ? ? ?將字符串nptr轉換成長整數并返回這個整數

char ?*ecvt(double value,int ndigit,int *decpt,int *sign)

將浮點數value轉換成字符串并返回該字符串

char ?*fcvt(double value,int ndigit,int *decpt,int *sign)

將浮點數value轉換成字符串并返回該字符串

char ?*gcvt(double value,int ndigit,char *buf)

將數value轉換成字符串并存于buf中,并返回buf的指針

char *ultoa(unsigned long value,char *string,int radix)

將無符號整型數value轉換成字符串并返回該字符串,radix為轉換時所用基數

char ?*ltoa(long value,char *string,int radix)

將長整型數value轉換成字符串并返回該字符串,radix為轉換時所用基數

char ?*itoa(int value,char *string,int radix)

將整數value轉換成字符串存入string,radix為轉換時所用基數

double atof(char *nptr) 將字符串nptr轉換成雙精度數,并返回這個數,錯誤返回0

int ?atoi(char *nptr) 將字符串nptr轉換成整型數, 并返回這個數,錯誤返回0

long ?atol(char *nptr) 將字符串nptr轉換成長整型數,并返回這個數,錯誤返回0

double strtod(char *str,char **endptr)將字符串str轉換成雙精度數,并返回這個數,

long ?strtol(char *str,char **endptr,int base)將字符串str轉換成長整型數,

并返回這個數,

int ? ? matherr(struct exception *e)

用戶修改數學錯誤返回信息函數(沒有必要使用)

double ? ?_matherr(_mexcep why,char *fun,double *arg1p,

double *arg2p,double retval)

用戶修改數學錯誤返回信息函數(沒有必要使用)

unsigned int _clear87() ?清除浮點狀態字并返回原來的浮點狀態

void ? ? _fpreset() ?重新初使化浮點數學程序包

unsigned int _status87() 返回浮點狀態字

目錄函數

所在函數庫為dir.hdos.h

int ? ? chdir(char *path) 使指定的目錄path(如:"C:\\WPS")變成當前的工作目錄,成

功返回0

int?findfirst(char *pathname,struct ffblk *ffblk,int attrib)查找指定的文件,成功

返回0

pathname為指定的目錄名和文件名,如"C:\\WPS\\TXT"

ffblk為指定的保存文件信息的一個結構,定義如下:

struct ffblk
{
char ff_reserved[21]; /*DOS保留字*/
char ff_attrib; /*文件屬性*/
int ff_ftime; /*文件時間*/
int ff_fdate; /*文件日期*/
long ff_fsize; /*文件長度*/
char ff_name[13]; /*文件名*/
}

attrib為文件屬性,由以下字符代表

┃FA_RDONLY?只讀文件┃FA_LABEL ?卷標號┃

┃FA_HIDDEN 隱藏文件┃FA_DIREC ?目錄 ?┃

┃FA_SYSTEM?系統文件┃FA_ARCH ? 檔案 ?┃

例:

struct ffblk ff;

findfirst("*.wps",&ff,FA_RDONLY);

int ? findnext(struct ffblk *ffblk) ? ? ?取匹配finddirst的文件,成功返回0

void ?fumerge(char *path,char *drive,char *dir,char *name,char *ext)

此函數通過盤符drive(C:、A:等),路徑dir(\TC、\BC\LIB等),

文件名name(TC、WPS等),擴展名ext(.EXE、.COM等)組成一個文件名

存與path中.

int ? fnsplit(char *path,char *drive,char *dir,char *name,char *ext)

此函數將文件名path分解成盤符drive(C:、A:等),路徑dir(\TC、\BC\LIB等),

文件名name(TC、WPS等),擴展名ext(.EXE、.COM等),并分別存入相應的變量中.

int ??getcurdir(int drive,char *direc) 此函數返回指定驅動器的當前工作目錄名稱

drive 指定的驅動器(0=當前,1=A,2=B,3=C等)

direc 保存指定驅動器當前工作路徑的變量 ? ? ?成功返回0

char *getcwd(char *buf,iint n) 此函數取當前工作目錄并存入buf中,直到n個字

節長為為止.錯誤返回NULL

int ??getdisk() 取當前正在使用的驅動器,返回一個整數(0=A,1=B,2=C等)

int ? setdisk(int drive) 設置要使用的驅動器drive(0=A,1=B,2=C等),

返回可使用驅動器總數

int ? mkdir(char *pathname) ?建立一個新的目錄pathname,成功返回0

int ? rmdir(char *pathname) ?刪除一個目錄pathname,成功返回0

char *mktemp(char *template) 構造一個當前目錄上沒有的文件名并存于template中

char *searchpath(char *pathname) 利用MSDOS找出文件filename所在路徑,

,此函數使用DOS的PATH變量,未找到文件返回NULL

進程函數

所在函數庫為stdlib.hprocess.h

void ?abort() 此函數通過調用具有出口代碼3的_exit寫一個終止信息于

stderr,并異常終止程序 無返回值

int ? exec…裝入和運行其它程序

int ? execl( ?char *pathname,char *arg0,char *arg1,…,char *argn,NULL)

int ? execle( char *pathname,char *arg0,char *arg1,…,

char *argn,NULL,char *envp[])

int ? execlp( char *pathname,char *arg0,char *arg1,…,NULL)

int execlpe(char *pathname,char *arg0,char *arg1,…,NULL,char *envp[])

int ? execv( ?char *pathname,char *argv[])

int ? execve( char *pathname,char *argv[],char *envp[])

int ? execvp( char *pathname,char *argv[])

int ? execvpe(char *pathname,char *argv[],char *envp[])

exec函數族裝入并運行程序pathname,并將參數

arg0(arg1,arg2,argv[],envp[])傳遞給子程序,出錯返回-1

在exec函數族中,后綴l、v、p、e添加到exec后,

所指定的函數將具有某種操作能力

有后綴 ?p時,函數可以利用DOS的PATH變量查找子程序文件

l時,函數中被傳遞的參數個數固定

v時,函數中被傳遞的參數個數不固定

e時,函數傳遞指定參數envp,允許改變子進程的環境,

無后綴e時,子進程使用當前程序的環境

void ?_exit(int status)終止當前程序,但不清理現場

void ?exit(int status) 終止當前程序,關閉所有文件,寫緩沖區的輸出(等待輸出),

并調用任何寄存器的"出口函數",無返回值

int ? spawn…運行子程序

int ??spawnl( ?int mode,char *pathname,char *arg0,char *arg1,…,

char *argn,NULL)

int ??spawnle( int mode,char *pathname,char *arg0,char *arg1,…,

char *argn,NULL,char *envp[])

int ? spawnlp( int mode,char *pathname,char *arg0,char *arg1,…,

char *argn,NULL)

int ? spawnlpe(int mode,char *pathname,char *arg0,char *arg1,…,

char *argn,NULL,char *envp[])

int ? spawnv( ?int mode,char *pathname,char *argv[])

int ? spawnve( int mode,char *pathname,char *argv[],char *envp[])

int ? spawnvp( int mode,char *pathname,char *argv[])

int ? spawnvpe(int mode,char *pathname,char *argv[],char *envp[])

spawn函數族在mode模式下運行子程序pathname,并將參數

arg0(arg1,arg2,argv[],envp[])傳遞給子程序.出錯返回-1

mode為運行模式

mode為 P_WAIT ? 表示在子程序運行完后返回本程序

P_NOWAIT 表示在子程序運行時同時運行本程序(不可用)

P_OVERLAY表示在本程序退出后運行子程序

在spawn函數族中,后綴l、v、p、e添加到spawn后,

所指定的函數將具有某種操作能力

有后綴 p時, 函數利用DOS的PATH查找子程序文件

l時, 函數傳遞的參數個數固定.

v時, 函數傳遞的參數個數不固定.

e時, 指定參數envp可以傳遞給子程序,允許改變子程序運行環境.

當無后綴e時,子程序使用本程序的環境.

int ? system(char *command) 將MSDOS命令command傳遞給DOS執行

轉換子程序,函數庫為math.h、stdlib.h、ctype.h、float.h

char ? *ecvt(double value,int ndigit,int *decpt,int *sign)

將浮點數value轉換成字符串并返回該字符串

char ? *fcvt(double value,int ndigit,int *decpt,int *sign)

將浮點數value轉換成字符串并返回該字符串

char ? *gcvt(double value,int ndigit,char *buf)

將數value轉換成字符串并存于buf中,并返回buf的指針

char ?*ultoa(unsigned long value,char *string,int radix)

將無符號整型數value轉換成字符串并返回該字符串,radix為轉換時所用基數

char ? *ltoa(long value,char *string,int radix)

將長整型數value轉換成字符串并返回該字符串,radix為轉換時所用基數

char ? *itoa(int value,char *string,int radix)

將整數value轉換成字符串存入string,radix為轉換時所用基數

double atof(char *nptr) 將字符串nptr轉換成雙精度數,并返回這個數,錯誤返回0

int ? ?atoi(char *nptr) 將字符串nptr轉換成整型數, ?并返回這個數,錯誤返回0

long ? atol(char *nptr) 將字符串nptr轉換成長整型數,并返回這個數,錯誤返回0

double strtod(char *str,char **endptr)將字符串str轉換成雙精度數,并返回這個數,

long ? strtol(char *str,char **endptr,int base)將字符串str轉換成長整型數,

并返回這個數,

int ? ?toascii(int c) ? 返回c相應的ASCII

int ? ?tolower(int ch) ?若ch是大寫字母('A'-'Z')返回相應的小寫字母('a'-'z')

int ? _tolower(int ch) ?返回ch相應的小寫字母('a'-'z')

int ? ?toupper(int ch) ?若ch是小寫字母('a'-'z')返回相應的大寫字母('A'-'Z')

int ? _toupper(int ch) ?返回ch相應的大寫字母('A'-'Z')

診斷函數

所在函數庫為assert.hmath.h

void ? assert(int test) 一個擴展成if語句那樣的宏,如果test測試失敗,

就顯示一個信息并異常終止程序,無返回值

void ? perror(char *string) 本函數將顯示最近一次的錯誤信息,格式如下:

字符串string:錯誤信息

char ? *strerror(char *str) 本函數返回最近一次的錯誤信息,格式如下:

字符串str:錯誤信息

int ? ?matherr(struct exception *e)

用戶修改數學錯誤返回信息函數(沒有必要使用)

double _matherr(_mexcep why,char *fun,double *arg1p,

double *arg2p,double retval)

用戶修改數學錯誤返回信息函數(沒有必要使用) 輸入輸出子程序,函數庫為io.h、conio.h、stat.h、dos.h、stdio.h、signal.h

int ? kbhit() ? ?本函數返回最近所敲的按鍵

int ??fgetchar() 從控制臺(鍵盤)讀一個字符,顯示在屏幕上

int ? getch() ? ?從控制臺(鍵盤)讀一個字符,不顯示在屏幕上

int ? putch() ? ?向控制臺(鍵盤)寫一個字符

int ? getchar() ?從控制臺(鍵盤)讀一個字符,顯示在屏幕上

int ? putchar() ?向控制臺(鍵盤)寫一個字符

int ? getche() ? 從控制臺(鍵盤)讀一個字符,顯示在屏幕上

int ??ungetch(int c) 把字符c退回給控制臺(鍵盤)

char *cgets(char *string) 從控制臺(鍵盤)讀入字符串存于string中

int ? scanf(char *format[,argument…])從控制臺讀入一個字符串,分別對各個參數進行

賦值,使用BIOS進行輸出

int ??vscanf(char *format,Valist param)從控制臺讀入一個字符串,分別對各個參數進行

賦值,使用BIOS進行輸出,參數從Valist param中取得

int ??cscanf(char *format[,argument…])從控制臺讀入一個字符串,分別對各個參數進行

賦值,直接對控制臺作操作,比如顯示器在顯示時字符時即為直接寫頻方式顯示

int ? sscanf(char *string,char *format[,argument,…])通過字符串string,分別對各個

參數進行賦值

int ??vsscanf(char *string,char *format,Vlist param)通過字符串string,分別對各個

參數進行賦值,參數從Vlist param中取得

int ? puts(char *string) ?發關一個字符串string給控制臺(顯示器),

使用BIOS進行輸出

void ?cputs(char *string) 發送一個字符串string給控制臺(顯示器),

直接對控制臺作操作,比如顯示器即為直接寫頻方式顯示

int ? printf(char *format[,argument,…]) 發送格式化字符串輸出給控制臺(顯示器)

使用BIOS進行輸出

int ? vprintf(char *format,Valist param) 發送格式化字符串輸出給控制臺(顯示器)

使用BIOS進行輸出,參數從Valist param中取得

int ? cprintf(char *format[,argument,…]) 發送格式化字符串輸出給控制臺(顯示器),

直接對控制臺作操作,比如顯示器即為直接寫頻方式顯示

int ? vcprintf(char *format,Valist param)發送格式化字符串輸出給控制臺(顯示器),

直接對控制臺作操作,比如顯示器即為直接寫頻方式顯示,

參數從Valist param中取得

int ? sprintf(char *string,char *format[,argument,…])

將字符串string的內容重新寫為格式化后的字符串

int ? vsprintf(char *string,char *format,Valist param)

將字符串string的內容重新寫為格式化后的字符串,參數從Valist param中取得

int ? rename(char *oldname,char *newname)將文件oldname的名稱改為newname

int ? ioctl(int handle,int cmd[,int *argdx,int argcx])

本函數是用來控制輸入/輸出設備的,請見下表:

┌───┬────────────────────────────┐

│cmd值 │功能 │

├───┼────────────────────────────┤

│ ?0 ? │取出設備信息 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?│

│ ?1 ? │設置設備信息 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?│

│ ?2 ? │把argcx字節讀入由argdx所指的地址 ? ? ? ? ? ? ? ? ? ? ? ?│

│ ?3 ? │在argdx所指的地址寫argcx字節 ? ? ? ? ? ? ? ? ? ? ? ? ? ?│

│ ?4 ? │除把handle當作設備號(0=當前,1=A,等)之外,均和cmd=2時一樣 │

│ ?5 ? │除把handle當作設備號(0=當前,1=A,等)之外,均和cmd=3時一樣 │

│ ?6 ? │取輸入狀態 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?│

│ ?7 ? │取輸出狀態 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?│

│ ?8 ? │測試可換性;只對于DOS 3.x ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?│

│ ?11 ?│置分享沖突的重算計數;只對DOS 3.x ? ? ? ? ? ? ? ? ? ? ? ?│

└───┴────────────────────────────┘

int ? (*ssignal(int sig,int(*action)())()執行軟件信號(沒必要使用)

int ? gsignal(int sig) ? ? ? ? ? ? ? ? ? 執行軟件信號(沒必要使用)

int ? _open(char *pathname,int access)為讀或寫打開一個文件,

按后按access來確定是讀文件還是寫文件,access值見下表

┌──────┬────────────────────┐

│access值 ? ?│意義 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?│

├──────┼────────────────────┤

│O_RDONLY ? ?│讀文件 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?│

│O_WRONLY ? ?│寫文件 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?│

│O_RDWR ? ? ?│即讀也寫 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?│

│O_NOINHERIT │若文件沒有傳遞給子程序,則被包含 ? ? ? ? │

│O_DENYALL ? │只允許當前處理必須存取的文件 ? ? ? ? ? ?│

│O_DENYWRITE │只允許從任何其它打開的文件讀 ? ? ? ? ? ?│

│O_DENYREAD ?│只允許從任何其它打開的文件寫 ? ? ? ? ? ?│

│O_DENYNONE ?│允許其它共享打開的文件 ? ? ? ? ? ? ? ? ?│

└──────┴────────────────────┘

接口子程序

所在函數庫為:dos.hbios.h

unsigned sleep(unsigned seconds)暫停seconds微秒(百分之一秒)

int ? ? ?unlink(char *filename)刪除文件filename

unsigned?FP_OFF(void far *farptr)本函數用來取遠指針farptr的偏移量

unsigned?FP_SEG(void far *farptr)本函數用來沒置遠指針farptr的段值

void far *MK_FP(unsigned seg,unsigned off)根據段seg和偏移量off構造一個far指針

unsigned getpsp()取程序段前綴的段地址,并返回這個地址

char *parsfnm(char *cmdline,struct fcb *fcbptr,int option)

函數分析一個字符串,通常,對一個文件名來說,是由cmdline所指的一個命令行.

文件名是放入一個FCB中作為一個驅動器,文件名和擴展名.FCB是由fcbptr所指

定的.option參數是DOS分析系統調用時,AL文本的值.

int ??absread(int drive,int nsects,int sectno,void *buffer)本函數功能為讀特定的

磁盤扇區,drive為驅動器號(0=A,1=B等),nsects為要讀的扇區數,sectno為開始的邏

輯扇區號,buffer為保存所讀數據的保存空間

int ??abswrite(int drive,int nsects,int sectno,void *buffer)本函數功能為寫特定的

磁盤扇區,drive為驅動器號(0=A,1=B等),nsects為要寫的扇區數,sectno為開始的邏

輯扇區號,buffer為保存所寫數據的所在空間

void ?getdfree(int drive,struct dfree *dfreep)本函數用來取磁盤的自由空間,

drive為磁盤號(0=當前,1=A等).函數將磁盤特性的由dfreep指向的dfree結構中.

dfree結構如下:

┌───────────────────┐

│struct dfree ? ? ? ? ? ? ? ? ? ? ? ? ?│

│{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

│ unsigned df_avail; /*有用簇個數*/ ? ?│

│ unsigned df_total; /*總共簇個數*/ ? ?│

│ unsigned df_bsec; ?/*每個扇區字節數*/│

│ unsigned df_sclus; /*每個簇扇區數*/ ?│

│} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

└───────────────────┘

char far *getdta() ? ? ? ? ? ? 取磁盤轉換地址DTA

void ? ? ?setdta(char far *dta)設置磁盤轉換地址DTA

void ?getfat(int drive,fatinfo *fatblkp)

本函數返回指定驅動器drive(0=當前,1=A,2=B等)的文件分配表信息

并存入結構fatblkp中,結構如下:

┌──────────────────┐

│struct fatinfo ? ? ? ? ? ? ? ? ? ? ?│

│{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

│ char fi_sclus; /*每個簇扇區數*/ ? ?│

│ char fi_fatid; /*文件分配表字節數*/│

│ int ?fi_nclus; /*簇的數目*/ ? ? ? ?│

│ int ?fi_bysec; /*每個扇區字節數*/ ?│

│} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

└──────────────────┘

void ?getfatd(struct fatinfo *fatblkp) 本函數返回當前驅動器的文件分配表信息,

并存入結構fatblkp中,結構如下:

┌──────────────────┐

│struct fatinfo ? ? ? ? ? ? ? ? ? ? ?│

│{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

│ char fi_sclus; /*每個簇扇區數*/ ? ?│

│ char fi_fatid; /*文件分配表字節數*/│

│ int ?fi_nclus; /*簇的數目*/ ? ? ? ?│

│ int ?fi_bysec; /*每個扇區字節數*/ ?│

│} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

└──────────────────┘

int ? bdos(int dosfun,unsigned dosdx,unsigned dosal)本函數對MSDOS系統進行調用,

dosdx為寄存器dx的值,dosal為寄存器al的值,dosfun為功能號

int ??bdosptr(int dosfun,void *argument,unsiigned dosal)本函數對MSDOS系統進行調用,

argument為寄存器dx的值,dosal為寄存器al的值,dosfun為功能號

int ??int86(int intr_num,union REGS *inregs,union REGS *outregs)

執行intr_num號中斷,用戶定義的寄存器值存于結構inregs中,

執行完后將返回的寄存器值存于結構outregs中.

int ? int86x(int intr_num,union REGS *inregs,union REGS *outregs,

struct SREGS *segregs)執行intr_num號中斷,用戶定義的寄存器值存于

結構inregs中和結構segregs中,執行完后將返回的寄存器值存于結構outregs中.

int ? intdos(union REGS *inregs,union REGS *outregs)

本函數執行DOS中斷0x21來調用一個指定的DOS函數,用戶定義的寄存器值

存于結構inregs中,執行完后函數將返回的寄存器值存于結構outregs中

int?intdosx(union REGS *inregs,union REGS *outregs,struct SREGS *segregs)

本函數執行DOS中斷0x21來調用一個指定的DOS函數,用戶定義的寄存器值

存于結構inregs和segregs中,執行完后函數將返回的寄存器值存于結構outregs中

void ?intr(int intr_num,struct REGPACK *preg)本函數中一個備用的8086軟件中斷接口

它能產生一個由參數intr_num指定的8086軟件中斷.函數在執行軟件中斷前,

從結構preg復制用戶定義的各寄存器值到各個寄存器.軟件中斷完成后,

函數將當前各個寄存器的值復制到結構preg中.參數如下:

intr_num 被執行的中斷號

preg為保存用戶定義的寄存器值的結構,結構如下

┌──────────────────────┐

│struct REGPACK ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?│

│{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

│ unsigned r_ax,r_bx,r_cx,r_dx; ? ? ? ? ? ? ?│

│ unsigned r_bp,r_si,r_di,r_ds,r_es,r_flags; │

│} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

└──────────────────────┘

函數執行完后,將新的寄存器值存于結構preg中

void ?keep(int status,int size)以status狀態返回MSDOS,但程序仍保留于內存中,所占

用空間由size決定.

void ?ctrlbrk(int (*fptr)()) 設置中斷后的對中斷的處理程序.

void ?disable() 禁止發生中斷

void ?enable() ?允許發生中斷

void ?geninterrupt(int intr_num)執行由intr_num所指定的軟件中斷

void ?interrupt(* getvect(int intr_num))() 返回中斷號為intr_num的中斷處理程序,

例如: old_int_10h=getvect(0x10);

void ?setvect(int intr_num,void interrupt(* isr)()) 設置中斷號為intr_num的中

斷處理程序為isr,例如: setvect(0x10,new_int_10h);

void ?harderr(int (*fptr)()) 定義一個硬件錯誤處理程序,

每當出現錯誤時就調用fptr所指的程序

void ?hardresume(int rescode)硬件錯誤處理函數

void ?hardretn(int errcode) ?硬件錯誤處理函數

int ??inport(int prot) 從指定的輸入端口讀入一個字,并返回這個字

int ??inportb(int port)從指定的輸入端口讀入一個字節,并返回這個字節

void ?outport(int port,int word) 將字word寫入指定的輸出端口port

void ?outportb(int port,char byte)將字節byte寫入指定的輸出端口port

int ? peek(int segment,unsigned offset) 函數返回segment:offset處的一個字

char ?peekb(int segment,unsigned offset)函數返回segment:offset處的一個字節

void ?poke(int segment,int offset,char value) 將字value寫到segment:offset處

void ?pokeb(int segment,int offset,int value) 將字節value寫到segment:offset處

int ? randbrd(struct fcb *fcbptr,int reccnt)

函數利用打開fcbptr所指的FCB讀reccnt個記錄.

int ??randbwr(struct fcb *fcbptr,int reccnt)

函數將fcbptr所指的FCB中的reccnt個記錄寫到磁盤上

void ?segread(struct SREGS *segtbl)函數把段寄存器的當前值放進結構segtbl中

int ??getverify() ? ? ? ? 取檢驗標志的當前狀態(0=檢驗關閉,1=檢驗打開)

void ?setverify(int value)設置當前檢驗狀態,

value為0表示關閉檢驗,為1表示打開檢驗

int ??getcbrk()本函數返回控制中斷檢測的當前設置

int ? setcbrk(int value)本函數用來設置控制中斷檢測為接通或斷開

當value=0時,為斷開檢測.當value=1時,為接開檢測

int ? dosexterr(struct DOSERR *eblkp)取擴展錯誤.在DOS出現錯誤后,此函數將擴充的

錯誤信息填入eblkp所指的DOSERR結構中.該結構定義如下:

┌──────────────┐

│struct DOSERR ? ? ? ? ? ? ? │

│{ ? ? ? ? ? ? ? ? ? ? ? ? ? │

│ int ?exterror;/*擴展錯誤*/ │

│ char class; ? /*錯誤類型*/ │

│ char action; ?/*方式*/ ? ? │

│ char locus; ? /*錯誤場所*/ │

│} ? ? ? ? ? ? ? ? ? ? ? ? ? │

└──────────────┘

操作函數

所在函數庫為string.hmem.h

mem…操作存貯數組

void *memccpy(void *destin,void *source,unsigned char ch,unsigned n)

void *memchr(void *s,char ch,unsigned n)

void *memcmp(void *s1,void *s2,unsigned n)

int ??memicmp(void *s1,void *s2,unsigned n)

void *memmove(void *destin,void *source,unsigned n)

void *memcpy(void *destin,void *source,unsigned n)

void *memset(void *s,char ch,unsigned n)

這些函數,mem…系列的所有成員均操作存貯數組.在所有這些函數中,數組是n字節長.

memcpy從source復制一個n字節的塊到destin.如果源塊和目標塊重疊,則選擇復制方向,

以例正確地復制覆蓋的字節.

memmove與memcpy相同.

memset將s的所有字節置于字節ch中.s數組的長度由n給出.

memcmp比較正好是n字節長的兩個字符串s1和s2.些函數按無符號字符比較字節,因此,

memcmp("0xFF","\x7F",1)返回值大于0.

memicmp比較s1和s2的前n個字節,不管字符大寫或小寫.

memccpy從source復制字節到destin.復制一結束就發生下列任一情況:

(1)字符ch首選復制到destin.

(2)n個字節已復制到destin.

memchr對字符ch檢索s數組的前n個字節.

返回值:memmove和memcpy返回destin

memset返回s的值

memcmp和memicmp─┬─若s1<s2返回值小于0

├─若s1=s2返回值等于0

└─若s1>s2返回值大于0

memccpy若復制了ch,則返回直接跟隨ch的在destin中的字節的一個指針;

否則返回NULL

memchr返回在s中首先出現ch的一個指針;如果在s數組中不出現ch,就返回NULL.

void ?movedata(int segsrc,int offsrc,

int segdest,int offdest,

unsigned numbytes)

本函數將源地址(segsrc:offsrc)處的numbytes個字節

復制到目標地址(segdest:offdest)

void ?movemem(void *source,void *destin,unsigned len)

本函數從source處復制一塊長len字節的數據到destin.若源地址和目標地址字符串

重疊,則選擇復制方向,以便正確的復制數據.

void ?setmem(void *addr,int len,char value)

本函數把addr所指的塊的第一個字節置于字節value中.

str…字符串操作函數

char ? stpcpy(char *dest,const char *src)

將字符串src復制到dest

char ? strcat(char *dest,const char *src)

將字符串src添加到dest末尾

char ? strchr(const char *s,int c)

檢索并返回字符c在字符串s中第一次出現的位置

int ? ?strcmp(const char *s1,const char *s2)

比較字符串s1與s2的大小,并返回s1-s2

char ? strcpy(char *dest,const char *src)

將字符串src復制到dest

size_t?strcspn(const char *s1,const char *s2)

掃描s1,返回在s1中有,在s2中也有的字符個數

char ? strdup(const char *s)

將字符串s復制到最近建立的單元

int ? ?stricmp(const char *s1,const char *s2)

比較字符串s1和s2,并返回s1-s2

size_t?strlen(const char *s)

返回字符串s的長度

char ? strlwr(char *s)

將字符串s中的大寫字母全部轉換成小寫字母,并返回轉換后的字符串

char ? strncat(char *dest,const char *src,size_t?maxlen)

將字符串src中最多maxlen個字符復制到字符串dest中

int ? ?strncmp(const char *s1,const char *s2,size_t?maxlen)

比較字符串s1與s2中的前maxlen個字符

char ? strncpy(char *dest,const char *src,size_t?maxlen)

復制src中的前maxlen個字符到dest中

int ? ?strnicmp(const char *s1,const char *s2,size_t?maxlen)

比較字符串s1與s2中的前maxlen個字符

char ??strnset(char *s,int ch,size_t?n)

將字符串s的前n個字符置于ch中

char ? strpbrk(const char *s1,const char *s2)

掃描字符串s1,并返回在s1和s2中均有的字符個數

char ? strrchr(const char *s,int c)

掃描最后出現一個給定字符c的一個字符串s

char ? strrev(char *s)

將字符串s中的字符全部顛倒順序重新排列,并返回排列后的字符串

char ??strset(char *s,int ch)

將一個字符串s中的所有字符置于一個給定的字符ch

size_t?strspn(const char *s1,const char *s2)

掃描字符串s1,并返回在s1和s2中均有的字符個數

char ? strstr(const char *s1,const char *s2)

掃描字符串s2,并返回第一次出現s1的位置

char ? strtok(char *s1,const char *s2)

檢索字符串s1,該字符串s1是由字符串s2中定義的定界符所分隔

char ??strupr(char *s)

將字符串s中的小寫字母全部轉換成大寫字母,并返回轉換后的字符串

存貯分配子程序,所在函數庫為dos.h、alloc.h、malloc.h、stdlib.h、process.h

int ? ?allocmem(unsigned size,unsigned *seg)利用DOS分配空閑的內存,

size為分配內存大小,seg為分配后的內存指針

int ? ?freemem(unsigned seg)釋放先前由allocmem分配的內存,seg為指定的內存指針

int ? ?setblock(int seg,int newsize)本函數用來修改所分配的內存長度,

seg為已分配內存的內存指針,newsize為新的長度

int ? ?brk(void *endds)

本函數用來改變分配給調用程序的數據段的空間數量,新的空間結束地址為endds

char ?*sbrk(int incr)

本函數用來增加分配給調用程序的數據段的空間數量,增加incr個字節的空間

unsigned long?coreleft() 本函數返回未用的存儲區的長度,以字節為單位

void ?*calloc(unsigned nelem,unsigned elsize)分配nelem個長度為elsize的內存空間

并返回所分配內存的指針

void ?*malloc(unsigned size)分配size個字節的內存空間,并返回所分配內存的指針

void ? free(void *ptr)釋放先前所分配的內存,所要釋放的內存的指針為ptr

void ?*realloc(void *ptr,unsigned newsize)改變已分配內存的大小,ptr為已分配有內

存區域的指針,newsize為新的長度,返回分配好的內存指針.

long ? farcoreleft() 本函數返回遠堆中未用的存儲區的長度,以字節為單位

void far *farcalloc(unsigned long units,unsigned long unitsz)

從遠堆分配units個長度為unitsz的內存空間,并返回所分配內存的指針

void ?*farmalloc(unsigned long size)分配size個字節的內存空間,

并返回分配的內存指針

void ? farfree(void far *block)釋放先前從遠堆分配的內存空間,

所要釋放的遠堆內存的指針為block

void far *farrealloc(void far *block,unsigned long newsize)改變已分配的遠堆內

存的大小,block為已分配有內存區域的指針,newzie為新的長度,返回分配好

的內存指針

時間日期函數

函數庫為time.hdos.h

在時間日期函數里,主要用到的結構有以下幾個:

總時間日期貯存結構tm

┌──────────────────────┐

│struct tm ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

│{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

│ int tm_sec; ? /*秒,0-59*/ ? ? ? ? ? ? ? ? ?│

│ int tm_min; ? /*分,0-59*/ ? ? ? ? ? ? ? ? ?│

│ int tm_hour; ?/*時,0-23*/ ? ? ? ? ? ? ? ? ?│

│ int tm_mday; ?/*天數,1-31*/ ? ? ? ? ? ? ? ?│

│ int tm_mon; ? /*月數,0-11*/ ? ? ? ? ? ? ? ?│

│ int tm_year; ?/*自1900的年數*/ ? ? ? ? ? ? │

│ int tm_wday; ?/*自星期日的天數0-6*/ ? ? ? ?│

│ int tm_yday; ?/*自1月1日起的天數,0-365*/ ? │

│ int tm_isdst; /*是否采用夏時制,采用為正數*/│

│} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

└──────────────────────┘

日期貯存結構date

┌───────────────┐

│struct date ? ? ? ? ? ? ? ? ? │

│{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

│ int da_year; /*自1900的年數*/│

│ char da_day; /*天數*/ ? ? ? ?│

│ char da_mon; /*月數 1=Jan*/ ?│

│} ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

└───────────────┘

時間貯存結構time

┌────────────────┐

│struct time ? ? ? ? ? ? ? ? ? ? │

│{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? │

│ unsigned char ti_min; ?/*分鐘*/│

│ unsigned char ti_hour; /*小時*/│

│ unsigned char ti_hund; ? ? ? ? │

│ unsigned char ti_sec; ?/*秒*/ ?│

│ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?│

└────────────────┘char ? ? ?*ctime(long *clock)

本函數把clock所指的時間(如由函數time返回的時間)轉換成下列格式的

字符串:Mon Nov 21 11:31:54 1983\n\0

char ? ? ?*asctime(struct tm *tm)

本函數把指定的tm結構類的時間轉換成下列格式的字符串:

Mon Nov 21 11:31:54 1983\n\0

double ? ??difftime(time_t time2,time_t time1)

計算結構time2和time1之間的時間差距(以秒為單位)

struct tm *gmtime(long *clock)本函數把clock所指的時間(如由函數time返回的時間)

轉換成格林威治時間,并以tm結構形式返回

struct tm *localtime(long *clock)本函數把clock所指的時間(如函數time返回的時間)

轉換成當地標準時間,并以tm結構形式返回

void ? ? ? tzset()本函數提供了對UNIX操作系統的兼容性

long ? ? ??dostounix(struct date *dateptr,struct time *timeptr)

本函數將dateptr所指的日期,timeptr所指的時間轉換成UNIX格式,并返回

自格林威治時間1970年1月1日凌晨起到現在的秒數

void ? ? ? unixtodos(long utime,struct date *dateptr,struct time *timeptr)

本函數將自格林威治時間1970年1月1日凌晨起到現在的秒數utime轉換成

DOS格式并保存于用戶所指的結構dateptr和timeptr中

void ? ? ? getdate(struct date *dateblk)本函數將計算機內的日期寫入結構dateblk

中以供用戶使用

void ? ? ??setdate(struct date *dateblk)本函數將計算機內的日期改成

由結構dateblk所指定的日期

void ? ? ? gettime(struct time *timep)本函數將計算機內的時間寫入結構timep中,

以供用戶使用

void ? ? ??settime(struct time *timep)本函數將計算機內的時間改為

由結構timep所指的時間

long ? ? ? time(long *tloc)本函數給出自格林威治時間1970年1月1日凌晨至現在所經

過的秒數,并將該值存于tloc所指的單元中.

int ? ? ? ?stime(long *tp)本函數將tp所指的時間(例如由time所返回的時間)

寫入計算機中.

轉載于:https://www.cnblogs.com/landv/p/3588681.html

總結

以上是生活随笔為你收集整理的C语言_函数【转】的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。