C語言輸入輸出函數(shù)有很多,標準I/O函數(shù)中包含了如下幾個常用的函數(shù):

讓客戶滿意是我們工作的目標,不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領域值得信任、有價值的長期合作伙伴,公司提供的服務項目有:主機域名、網(wǎng)站空間、營銷軟件、網(wǎng)站建設、鐘山網(wǎng)站維護、網(wǎng)站推廣。
scanf,printf,getc,putc,getchar,putchar,gets,puts,fgets,fputs,fgetc,fputc,fscanf,fprintf等.
int getc(FILE *fp)
getc主要是從文件中讀出一個字符.常用的判斷文件是否讀取結束的語句為 (ch = getc(fp)) != EOF.EOF為文件結束標志,定義在stdio.h中,就像EXIT_SUCCESS,EXIT_FAILURE定義在stdlib.h中一樣,文件也可以被理解為一種流,所以當fp為stdin時,getc(stdin)就等同于getchar()了.
int putc(int ch,FILE *fp)
putc主要是把字符ch寫到文件fp中去.如果fp為stdout,則putc就等同于putchar()了.
int getchar(void)
getchar主要是從標準輸入流讀取一個字符.默認的標準輸入流即stdio.h中定義的stdin.但是從輸入流中讀取字符時又涉及到緩沖的問題,所以并不是在屏幕中敲上一個字符程序就會運行,一般是通過在屏幕上敲上回車鍵,然后將回車前的字符串放在緩沖區(qū)中,getchar就是在緩沖區(qū)中一個一個的讀字符.當然也可以在while循環(huán)中指定終止字符,如下面的語句:while ((c = getchar()) != '#')這是以#來結束的.
int putchar(int ch)
putchar(ch)主要是把字符ch寫到標準流stdout中去.
char * gets(char *str)
gets主要是從標準輸入流讀取字符串并回顯,讀到換行符時退出,并會將換行符省去.
int puts(char *str)
puts主要是把字符串str寫到標準流stdout中去,并會在輸出到最后時添加一個換行符.
char *fgets(char *str, int num, FILE *fp)
str是存放讀入的字符數(shù)組指針,num是最大允許的讀入字符數(shù),fp是文件指針.fgets的功能是讀一行字符,該行的字符數(shù)不大于num-1.因為fgets函數(shù)會在末尾加上一個空字符以構成一個字符串.另外fgets在讀取到換行符后不會將其省略.
int fputs(char *str, file *fp)
fputs將str寫入fp.fputs與puts的不同之處是fputs在打印時并不添加換行符.
int fgetc(FILE *fp)
fgetc從fp的當前位置讀取一個字符.
int fputc(int ch, file *fp)
fputc是將ch寫入fp當前指定位置.
int fscanf(FILE *fp, char *format, 輸入列表)
fscanf按照指定格式從文件中出讀出數(shù)據(jù),并賦值到參數(shù)列表中.
int fprintf(FILE *fp, char *format, 輸出列表)
fprintf將格式化數(shù)據(jù)寫入流式文件中.
數(shù)據(jù)塊讀寫函數(shù)
fread (buffer,size,count,fp);
fwrite(buffer,size,count,fp);
參數(shù)說明:
buffer:是一個指針。
對fread 來說,它是讀入數(shù)據(jù)的存放地址。
對fwrite來說,是要輸出數(shù)據(jù)的地址(均指起始地址)。
size: 要讀寫的字節(jié)數(shù)。
count: 要進行讀寫多少個size字節(jié)的數(shù)據(jù)項。
fp: 文件型指針。
C語言庫函數(shù),常用庫函數(shù)有:
1、scanf格式輸入函數(shù)
2、printf格式輸出函數(shù)
3、systemdos命令函數(shù)
4、sort排序
5、main主函數(shù)
6、fgets文件讀取字符串函數(shù)
7、fputs文件寫入字符串函數(shù)
8、fscanf文件格式讀取函數(shù)
9、fprintf文件格式寫入函數(shù)
10、fopen打開文件函數(shù)
11、getchar輸入字符函數(shù)
12、putchar輸出字符函數(shù)
13、malloc動態(tài)申請內(nèi)存函數(shù)
14、free釋放內(nèi)存函數(shù)
15、abs求絕對值數(shù)學函數(shù)
16、sqrt求平方根數(shù)學函數(shù)
擴展資料
語言組成:
1、數(shù)據(jù)類型
C的數(shù)據(jù)類型包括:整型、字符型、實型或浮點型(單精度和雙精度)、枚舉類型、數(shù)組類型、結構體類型、共用體類型、指針類型和空類型。
2、常量與變量
常量其值不可改變,符號常量名通常用大寫。
變量是以某標識符為名字,其值可以改變的量。標識符是以字母或下劃線開頭的一串由字母、數(shù)字或下劃線構成的序列,請注意第一個字符必須為字母或下劃線,否則為不合法的變量名。變量在編譯時為其分配相應存儲單元。
3、數(shù)組
如果一個變量名后面跟著一個有數(shù)字的中括號,這個聲明就是數(shù)組聲明。字符串也是一種數(shù)組。它們以ASCII的NULL作為數(shù)組的結束。要特別注意的是,方括內(nèi)的索引值是從0算起的。
4、指針
如果一個變量聲明時在前面使用 * 號,表明這是個指針型變量。換句話說,該變量存儲一個地址,而 *(此處特指單目運算符 * ,下同。C語言中另有 雙目運算符 *) 則是取內(nèi)容操作符,意思是取這個內(nèi)存地址里存儲的內(nèi)容。指針是 C 語言區(qū)別于其他同時代高級語言的主要特征之一。
參考資料來源:百度百科-函數(shù)
復制
#include
"stdio.h"
{char
s1[]="abcde",s2[]="scasasa";
strcpy(s1,s2);
如果s2長度大于s1則會覆蓋掉
如果小于的話只是將s2的\0放在s1中\(zhòng)0的前面罷了,而后面處理字符串的函數(shù)是遇到\0就收手
函數(shù)名:
strncpy
功
能:
串拷貝
用
法:
char
*strncpy(char
*destin,
char
*source,
int
maxlen);
程序例:
#include
#include
int
main(void)
{
char
string[10];
char
*str1
=
"abcdefghi";
strncpy(string,
str1,
3);
string[3]
=
'\0';
printf("%s\n",
string);
return
0;
}
函數(shù)名:
remove
功
能:
刪除一個文件
用
法:
int
remove(char
*filename);
程序例:
#include
int
main(void)
{
char
file[80];
/*
prompt
for
file
name
to
delete
*/
printf("file
to
delete:
");
gets(file);
/*
delete
the
file
*/
if
(remove(file)
==
0)
printf("removed
%s.\n",file);
else
perror("remove");
return
0;
}
函數(shù)名:
rename
功
能:
重命名文件
用
法:
int
rename(char
*oldname,
char
*newname);
程序例:
#include
int
main(void)
{
char
oldname[80],
newname[80];
/*
prompt
for
file
to
rename
and
new
name
*/
printf("file
to
rename:
");
gets(oldname);
printf("new
name:
");
gets(newname);
/*
rename
the
file
*/
if
(rename(oldname,
newname)
==
0)
printf("renamed
%s
to
%s.\n",
oldname,
newname);
else
perror("rename");
return
0;
}
C語言的常用庫函數(shù)
函數(shù)1。absread()讀磁盤絕對扇區(qū)函數(shù)
函數(shù)2。abswrite()寫磁盤絕對扇區(qū)函數(shù)
函數(shù)3。atof()將字符串轉換成浮點數(shù)的函數(shù)
函數(shù)4。atoi()將字符串轉換成整型數(shù)的函數(shù)
函數(shù)5。atol()將字符串轉換成長整型數(shù)的函數(shù)
函數(shù)6。bcd()把一個數(shù)轉換成對應的BCD碼的函數(shù)
函數(shù)7。bdos()
函數(shù)8。biosdisk()調用BIOS磁盤驅動程序函數(shù)
函數(shù)9。biosprint()調用BIOS打印機I/O接口的函數(shù)
函數(shù)10。calloc()分配內(nèi)存函數(shù)
函數(shù)11。ceil()
函數(shù)12。cgets()讀字符串函數(shù)
函數(shù)13。chdir()改變當前目錄的函數(shù)
函數(shù)14。_chmod()改變文件存取權限的函數(shù)
函數(shù)15。chmod()改變文件存取權限的函數(shù)
函數(shù)16。clock()
函數(shù)17。close()關閉文件函數(shù)
函數(shù)18。closegraph()關閉圖形函數(shù)
函數(shù)19。cos()
函數(shù)20。ctrlbrk()設置ctrl-break處理程序的函數(shù)
函數(shù)21。delay()暫停函數(shù)
函數(shù)22。disable()屏蔽中斷的宏
函數(shù)23。enable()開硬件中斷的宏
函數(shù)24。exec()加載并運行其它程序的函數(shù)族
函數(shù)25。farcalloc()從遠堆中分配內(nèi)存的函數(shù)
函數(shù)26。farfree()從遠堆中釋放一塊已分配內(nèi)存的函數(shù)
函數(shù)27。farmalloc()從遠堆中分配內(nèi)存的函數(shù)
函數(shù)28。farrealloc()調整遠堆中已分配塊的函數(shù)
函數(shù)29。fclose()關閉一個流函數(shù)
函數(shù)30。fcloseall()關閉打開的流的函數(shù)
函數(shù)31。feof()檢查文件是否結束的函數(shù)
函數(shù)32。fgets()從流中讀取一字符串的函數(shù)
函數(shù)33。findfirst()函數(shù)和findnext()函數(shù)
函數(shù)34。floodfill()填充區(qū)域的函數(shù)
函數(shù)35。floor()
函數(shù)36。fnmerge()建立文件路徑函數(shù)
函數(shù)37。fnsplit()分解完整的路徑名函數(shù)
函數(shù)38。fopen()打開一個流函數(shù)
函數(shù)39。FP_OFF()獲取遠地址偏移量的宏
函數(shù)40。fprintf()傳送輸出到一個流中的函數(shù)
函數(shù)41。FP_SEG()獲取遠地址段值的宏
函數(shù)42。fscanf()格式化輸入函數(shù)
函數(shù)43。fseek()移動文件指針函數(shù)
函數(shù)44。fwrite()把參數(shù)寫入流中的函數(shù)
函數(shù)45。gcvt()把雙精度數(shù)轉化成字符串的函數(shù)
函數(shù)46。geninterrupt()執(zhí)行中斷函數(shù)
函數(shù)47。getc()從流中取字符的宏
函數(shù)48。getch()從鍵盤無回顯地讀取一字符的函數(shù)
函數(shù)49。getchar()從stdin流中讀取一個字符的函數(shù)
函數(shù)50。getcurdir()讀取指定驅動器的當前目錄的函數(shù)
函數(shù)61。getcwd()讀取當前目錄的函數(shù)
函數(shù)62。getdate()讀取系統(tǒng)日期函數(shù)
函數(shù)63。getdfree()讀取磁盤空閑空間的函數(shù)
函數(shù)64。getdisk()讀取當前磁盤驅動器號函數(shù)
函數(shù)65。getenv()讀取環(huán)境變量的當前值的函數(shù)
函數(shù)66。getimage()將指定區(qū)域的位圖象存入內(nèi)存的函數(shù)
函數(shù)67。getmaxx()返回屏幕上最大的X坐標值的函數(shù)
函數(shù)68。getmaxy()返回屏幕上最大的Y坐標值的函數(shù)
函數(shù)69。getpixel()讀取像素顏色的函數(shù)
函數(shù)70。getpsp()
函數(shù)71。gets()從標準輸入流stdio中讀取一字符串的函數(shù)
函數(shù)72。gettime()讀取系統(tǒng)時間的函數(shù)
函數(shù)73。getvect()讀取中斷向量函數(shù)
函數(shù)74。getx()返回當前圖形方式下位置的X坐標值的函數(shù)
函數(shù)75。gety()返回當前圖形方式下位置的Y坐標值的函數(shù)
函數(shù)76。imagesize()返回保存圖像緩沖區(qū)大小的函數(shù)
函數(shù)77。initgraph()顯示模式控制函數(shù)(初始化圖形系統(tǒng)函數(shù))
函數(shù)78。inport()從端口中讀入一個字的函數(shù)
函數(shù)79。inportb()從端口讀入一個字節(jié)的函數(shù)
函數(shù)80。int86()執(zhí)行中斷函數(shù)(調用8086軟中斷函數(shù))
函數(shù)81。int86x()執(zhí)行中斷函數(shù) (通用8086軟中斷接口函數(shù))
函數(shù)82。intdos()通用dos中斷接口函數(shù)
函數(shù)83。intdosx()通用dos中斷接口函數(shù)
函數(shù)84。intr()執(zhí)行8086軟中斷函數(shù)(改變軟中斷接口函數(shù))
函數(shù)85。itoa()把整形數(shù)轉換為字符串的函數(shù)
函數(shù)86。kbhit()檢查當前按下的鍵的函數(shù)
函數(shù)87。keep()駐留并退出函數(shù)
函數(shù)88。log()
函數(shù)89。log10()
函數(shù)90。_lrotl()將一個無符號長整形數(shù)左循環(huán)移位的函數(shù)
函數(shù)91。_lrotr()將一個無符號長整形數(shù)右循環(huán)移位的函數(shù)
函數(shù)92。lseek()移動文件指針函數(shù)
函數(shù)93。ltoa()把長整形數(shù)轉換為字符串的函數(shù)
函數(shù)94。malloc()分配內(nèi)存函數(shù)
函數(shù)95。mkdir()創(chuàng)建目錄函數(shù)
函數(shù)96。mktemp()建立一個唯一的文件名的函數(shù)
函數(shù)97。MK_FP()設置一個遠指針的宏
函數(shù)98。movedata()拷貝數(shù)據(jù)函數(shù)
函數(shù)99。_open()打開一個文件進行讀寫的函數(shù)
函數(shù)100。open()打開文件進行讀寫的函數(shù)
函數(shù)101。outport()輸出一個字到端口中的函數(shù)
函數(shù)102。outportb()輸出一個字節(jié)到端口中的函數(shù)
函數(shù)103。outtextxy()在指定位置顯示一字符串的函數(shù)
函數(shù)104。peek()返回指定內(nèi)存中字的函數(shù)
函數(shù)105。peekb()返回指定內(nèi)存中字節(jié)的函數(shù)
函數(shù)106。poke()在指定的內(nèi)存中存儲一個字的函數(shù)
函數(shù)107。pokeb()在指定的內(nèi)存中存儲一個字節(jié)的函數(shù)
函數(shù)108。pow()
函數(shù)109。printf()寫格式化輸出到stdout的函數(shù)
函數(shù)110。putch()向屏幕輸出字符的函數(shù)
函數(shù)111。putchar()在stdout上輸出字符的宏
函數(shù)112。putenv()將字符串放入當前環(huán)境中的函數(shù)
函數(shù)113。putimage()重新寫屏函數(shù)(輸出一個位圖象到圖形屏幕上的函數(shù))
函數(shù)114。putpixel()寫像素點函數(shù)
函數(shù)115。puts()輸出一字符串到stdout(標準輸出)的函數(shù)
函數(shù)116。_read()讀文件函數(shù)
函數(shù)117。read()讀文件函數(shù)
函數(shù)118。realloc()重新分配內(nèi)存函數(shù)
函數(shù)119。rectangle()畫一個矩形的函數(shù)
函數(shù)120。remove()刪除一個文件的函數(shù)
函數(shù)121。rename()文件改名函數(shù)
函數(shù)122。restorecrtmode()恢復屏幕視頻模式為調用initgraph前的設置的函數(shù)
函數(shù)123。rmdir()刪除目錄函數(shù)
函數(shù)124。_rotl()將一個無符號整形數(shù)左循環(huán)移位的函數(shù)
函數(shù)125。_rotr()將一個無符號整形數(shù)右循環(huán)移位的函數(shù)
函數(shù)126。scanf()格式化輸入函數(shù)
函數(shù)127。searchpath()按dos路徑查找一個文件的函數(shù)
函數(shù)128。segread()讀段寄存器函數(shù)
函數(shù)129。setactivepage()設置圖形輸出活動頁的函數(shù)
函數(shù)130。setcolor()設置當前要畫的線顏色的函數(shù)
函數(shù)131。setdisk()設置當前驅動器的函數(shù)
函數(shù)132。setgraphmode()將系統(tǒng)設置成圖形模式并清屏的函數(shù)
函數(shù)133。setlinestyle()設置當前畫線寬度和類型的函數(shù)
函數(shù)134。settextstyle()顯示字符的當前設置函數(shù)
函數(shù)135。setvect()設置中斷向量函數(shù)
函數(shù)136。setviewport()建立視口的函數(shù)
函數(shù)137。setvisualpage()設置可見的圖形頁號的函數(shù)
函數(shù)138。sin()
函數(shù)139。sprintf()格式化輸出到數(shù)組的函數(shù)
函數(shù)140。strcat()
函數(shù)141。tan()
函數(shù)142。_write()寫文件函數(shù)
函數(shù)143。write()寫文件函數(shù)
原文釋義請到百度文庫里搜尋字串“C語言常用函數(shù)”后下載
函數(shù)51-60因原注里排序號碼少編,所以只有133個常用函數(shù)。
DOC大小是119.5KB
貢獻時間:2010-09-10
貢獻者:handanlinzhang
int isalpha(int ch) 若ch是字母('A'-'Z','a'-'z')返回非0值,否則返回0
int isalnum(int ch) 若ch是字母('A'-'Z','a'-'z')或數(shù)字('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是數(shù)字('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進制數(shù)('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')
========數(shù)學函數(shù)(原型聲明所在頭文件為math.h、stdlib.h、string.h、float.h)===========
int abs(int i) 返回整型參數(shù)i的絕對值
double cabs(struct complex znum) 返回復數(shù)znum的絕對值
double fabs(double x) 返回雙精度參數(shù)x的絕對值
long labs(long n) 返回長整型參數(shù)n的絕對值
double exp(double x) 返回指數(shù)函數(shù)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的最小整數(shù)
double floor(double x) 返回不大于x的最大整數(shù)
void srand(unsigned seed) 初始化隨機數(shù)發(fā)生器
int rand() 產(chǎn)生一個隨機數(shù)并返回這個數(shù)
double poly(double x,int n,double c[])從參數(shù)產(chǎn)生一個多項式
double modf(double value,double *iptr)將雙精度數(shù)value分解成尾數(shù)和階
double fmod(double x,double y) 返回x/y的余數(shù)
double frexp(double value,int *eptr) 將雙精度數(shù)value分成尾數(shù)和階
double atof(char *nptr) 將字符串nptr轉換成浮點數(shù)并返回這個浮點數(shù)
double atoi(char *nptr) 將字符串nptr轉換成整數(shù)并返回這個整數(shù)
double atol(char *nptr) 將字符串nptr轉換成長整數(shù)并返回這個整數(shù)
char *ecvt(double value,int ndigit,int *decpt,int *sign)
將浮點數(shù)value轉換成字符串并返回該字符串
char *fcvt(double value,int ndigit,int *decpt,int *sign)
將浮點數(shù)value轉換成字符串并返回該字符串
char *gcvt(double value,int ndigit,char *buf)
將數(shù)value轉換成字符串并存于buf中,并返回buf的指針
char *ultoa(unsigned long value,char *string,int radix)
將無符號整型數(shù)value轉換成字符串并返回該字符串,radix為轉換時所用基數(shù)
char *ltoa(long value,char *string,int radix)
將長整型數(shù)value轉換成字符串并返回該字符串,radix為轉換時所用基數(shù)
char *itoa(int value,char *string,int radix)
將整數(shù)value轉換成字符串存入string,radix為轉換時所用基數(shù)
double atof(char *nptr) 將字符串nptr轉換成雙精度數(shù),并返回這個數(shù),錯誤返回0
int atoi(char *nptr) 將字符串nptr轉換成整型數(shù), 并返回這個數(shù),錯誤返回0
long atol(char *nptr) 將字符串nptr轉換成長整型數(shù),并返回這個數(shù),錯誤返回0
double strtod(char *str,char **endptr)將字符串str轉換成雙精度數(shù),并返回這個數(shù),
long strtol(char *str,char **endptr,int base)將字符串str轉換成長整型數(shù),
并返回這個數(shù),
int matherr(struct exception *e)
用戶修改數(shù)學錯誤返回信息函數(shù)(沒有必要使用)
double _matherr(_mexcep why,char *fun,double *arg1p,
double *arg2p,double retval)
用戶修改數(shù)學錯誤返回信息函數(shù)(沒有必要使用)
unsigned int _clear87() 清除浮點狀態(tài)字并返回原來的浮點狀態(tài)
void _fpreset() 重新初使化浮點數(shù)學程序包
unsigned int _status87() 返回浮點狀態(tài)字
============目錄函數(shù)(原型聲明所在頭文件為dir.h、dos.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 系統(tǒng)文件┃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)
此函數(shù)通過盤符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)
此函數(shù)將文件名path分解成盤符drive(C:、A:等),路徑dir(\TC、\BC\LIB等),
文件名name(TC、WPS等),擴展名ext(.EXE、.COM等),并分別存入相應的變量中.
int getcurdir(int drive,char *direc) 此函數(shù)返回指定驅動器的當前工作目錄名稱
drive 指定的驅動器(0=當前,1=A,2=B,3=C等)
direc 保存指定驅動器當前工作路徑的變量 成功返回0
char *getcwd(char *buf,iint n) 此函數(shù)取當前工作目錄并存入buf中,直到n個字
節(jié)長為為止.錯誤返回NULL
int getdisk() 取當前正在使用的驅動器,返回一個整數(shù)(0=A,1=B,2=C等)
int setdisk(int drive) 設置要使用的驅動器drive(0=A,1=B,2=C等),
返回可使用驅動器總數(shù)
int mkdir(char *pathname) 建立一個新的目錄pathname,成功返回0
int rmdir(char *pathname) 刪除一個目錄pathname,成功返回0
char *mktemp(char *template) 構造一個當前目錄上沒有的文件名并存于template中
char *searchpath(char *pathname) 利用MSDOS找出文件filename所在路徑,
,此函數(shù)使用DOS的PATH變量,未找到文件返回NULL
===========進程函數(shù)(原型聲明所在頭文件為stdlib.h、process.h)===========
void abort() 此函數(shù)通過調用具有出口代碼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函數(shù)族裝入并運行程序pathname,并將參數(shù)
arg0(arg1,arg2,argv[],envp[])傳遞給子程序,出錯返回-1
在exec函數(shù)族中,后綴l、v、p、e添加到exec后,
所指定的函數(shù)將具有某種操作能力
有后綴 p時,函數(shù)可以利用DOS的PATH變量查找子程序文件。
l時,函數(shù)中被傳遞的參數(shù)個數(shù)固定。
v時,函數(shù)中被傳遞的參數(shù)個數(shù)不固定。
e時,函數(shù)傳遞指定參數(shù)envp,允許改變子進程的環(huán)境,
無后綴e時,子進程使用當前程序的環(huán)境。
void _exit(int status)終止當前程序,但不清理現(xiàn)場
void exit(int status) 終止當前程序,關閉所有文件,寫緩沖區(qū)的輸出(等待輸出),
并調用任何寄存器的"出口函數(shù)",無返回值
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函數(shù)族在mode模式下運行子程序pathname,并將參數(shù)
arg0(arg1,arg2,argv[],envp[])傳遞給子程序.出錯返回-1
mode為運行模式
mode為 P_WAIT 表示在子程序運行完后返回本程序
P_NOWAIT 表示在子程序運行時同時運行本程序(不可用)
P_OVERLAY表示在本程序退出后運行子程序
在spawn函數(shù)族中,后綴l、v、p、e添加到spawn后,
所指定的函數(shù)將具有某種操作能力
有后綴 p時, 函數(shù)利用DOS的PATH查找子程序文件
l時, 函數(shù)傳遞的參數(shù)個數(shù)固定.
v時, 函數(shù)傳遞的參數(shù)個數(shù)不固定.
e時, 指定參數(shù)envp可以傳遞給子程序,允許改變子程序運行環(huán)境.
當無后綴e時,子程序使用本程序的環(huán)境.
int system(char *command) 將MSDOS命令command傳遞給DOS執(zhí)行
======轉換子程序(函數(shù)原型所在頭文件為math.h、stdlib.h、ctype.h、float.h)========
char *ecvt(double value,int ndigit,int *decpt,int *sign)
將浮點數(shù)value轉換成字符串并返回該字符串
char *fcvt(double value,int ndigit,int *decpt,int *sign)
將浮點數(shù)value轉換成字符串并返回該字符串
char *gcvt(double value,int ndigit,char *buf)
將數(shù)value轉換成字符串并存于buf中,并返回buf的指針
char *ultoa(unsigned long value,char *string,int radix)
將無符號整型數(shù)value轉換成字符串并返回該字符串,radix為轉換時所用基數(shù)
char *ltoa(long value,char *string,int radix)
將長整型數(shù)value轉換成字符串并返回該字符串,radix為轉換時所用基數(shù)
char *itoa(int value,char *string,int radix)
將整數(shù)value轉換成字符串存入string,radix為轉換時所用基數(shù)
double atof(char *nptr) 將字符串nptr轉換成雙精度數(shù),并返回這個數(shù),錯誤返回0
int atoi(char *nptr) 將字符串nptr轉換成整型數(shù), 并返回這個數(shù),錯誤返回0
long atol(char *nptr) 將字符串nptr轉換成長整型數(shù),并返回這個數(shù),錯誤返回0
double strtod(char *str,char **endptr)將字符串str轉換成雙精度數(shù),并返回這個數(shù),
long strtol(char *str,char **endptr,int base)將字符串str轉換成長整型數(shù),
并返回這個數(shù),
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')
網(wǎng)頁題目:c語言函數(shù)大全速查手冊,c語言常用函數(shù)速查手冊pdf
標題網(wǎng)址:http://chinadenli.net/article32/dsgcesc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、品牌網(wǎng)站制作、網(wǎng)站導航、品牌網(wǎng)站設計、外貿(mào)網(wǎng)站建設、響應式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)