新聞中心
c語言中有哪些函數(shù)
C語言輸入輸出函數(shù)有很多,標(biāo)準(zhǔn)I/O函數(shù)中包含了如下幾個(gè)常用的函數(shù):
蜀山網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),蜀山網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為蜀山上1000+提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站制作要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的蜀山做網(wǎng)站的公司定做!
scanf,printf,getc,putc,getchar,putchar,gets,puts,fgets,fputs,fgetc,fputc,fscanf,fprintf等.
int
getc(FILE
*fp)
getc主要是從文件中讀出一個(gè)字符.常用的判斷文件是否讀取結(jié)束的語句為
(ch
=
getc(fp))
!=
EOF.EOF為文件結(jié)束標(biāo)志,定義在stdio.h中,就像EXIT_SUCCESS,EXIT_FAILURE定義在stdlib.h中一樣,文件也可以被理解為一種流,所以當(dāng)fp為stdin時(shí),getc(stdin)就等同于getchar()了.
int
putc(int
ch,FILE
*fp)
putc主要是把字符ch寫到文件fp中去.如果fp為stdout,則putc就等同于putchar()了.
int
getchar(void)
getchar主要是從標(biāo)準(zhǔn)輸入流讀取一個(gè)字符.默認(rèn)的標(biāo)準(zhǔn)輸入流即stdio.h中定義的stdin.但是從輸入流中讀取字符時(shí)又涉及到緩沖的問題,所以并不是在屏幕中敲上一個(gè)字符程序就會(huì)運(yùn)行,一般是通過在屏幕上敲上回車鍵,然后將回車前的字符串放在緩沖區(qū)中,getchar就是在緩沖區(qū)中一個(gè)一個(gè)的讀字符.當(dāng)然也可以在while循環(huán)中指定終止字符,如下面的語句:while
((c
=
getchar())
!=
'#')這是以#來結(jié)束的.
int
putchar(int
ch)
putchar(ch)主要是把字符ch寫到標(biāo)準(zhǔn)流stdout中去.
char
*
gets(char
*str)
gets主要是從標(biāo)準(zhǔn)輸入流讀取字符串并回顯,讀到換行符時(shí)退出,并會(huì)將換行符省去.
int
puts(char
*str)
puts主要是把字符串str寫到標(biāo)準(zhǔn)流stdout中去,并會(huì)在輸出到最后時(shí)添加一個(gè)換行符.
char
*fgets(char
*str,
int
num,
FILE
*fp)
str是存放讀入的字符數(shù)組指針,num是最大允許的讀入字符數(shù),fp是文件指針.fgets的功能是讀一行字符,該行的字符數(shù)不大于num-1.因?yàn)閒gets函數(shù)會(huì)在末尾加上一個(gè)空字符以構(gòu)成一個(gè)字符串.另外fgets在讀取到換行符后不會(huì)將其省略.
int
fputs(char
*str,
file
*fp)
fputs將str寫入fp.fputs與puts的不同之處是fputs在打印時(shí)并不添加換行符.
int
fgetc(FILE
*fp)
fgetc從fp的當(dāng)前位置讀取一個(gè)字符.
int
fputc(int
ch,
file
*fp)
fputc是將ch寫入fp當(dāng)前指定位置.
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:是一個(gè)指針。
對(duì)fread
來說,它是讀入數(shù)據(jù)的存放地址。
對(duì)fwrite來說,是要輸出數(shù)據(jù)的地址(均指起始地址)。
size:
要讀寫的字節(jié)數(shù)。
count:
要進(jìn)行讀寫多少個(gè)size字節(jié)的數(shù)據(jù)項(xiàng)。
fp:
文件型指針。
求C語言的常用函數(shù),詳細(xì)一點(diǎn)
C語言的常用庫(kù)函數(shù)
函數(shù)1。absread()讀磁盤絕對(duì)扇區(qū)函數(shù)
函數(shù)2。abswrite()寫磁盤絕對(duì)扇區(qū)函數(shù)
函數(shù)3。atof()將字符串轉(zhuǎn)換成浮點(diǎn)數(shù)的函數(shù)
函數(shù)4。atoi()將字符串轉(zhuǎn)換成整型數(shù)的函數(shù)
函數(shù)5。atol()將字符串轉(zhuǎn)換成長(zhǎng)整型數(shù)的函數(shù)
函數(shù)6。bcd()把一個(gè)數(shù)轉(zhuǎn)換成對(duì)應(yīng)的BCD碼的函數(shù)
函數(shù)7。bdos()
函數(shù)8。biosdisk()調(diào)用BIOS磁盤驅(qū)動(dòng)程序函數(shù)
函數(shù)9。biosprint()調(diào)用BIOS打印機(jī)I/O接口的函數(shù)
函數(shù)10。calloc()分配內(nèi)存函數(shù)
函數(shù)11。ceil()
函數(shù)12。cgets()讀字符串函數(shù)
函數(shù)13。chdir()改變當(dāng)前目錄的函數(shù)
函數(shù)14。_chmod()改變文件存取權(quán)限的函數(shù)
函數(shù)15。chmod()改變文件存取權(quán)限的函數(shù)
函數(shù)16。clock()
函數(shù)17。close()關(guān)閉文件函數(shù)
函數(shù)18。closegraph()關(guān)閉圖形函數(shù)
函數(shù)19。cos()
函數(shù)20。ctrlbrk()設(shè)置ctrl-break處理程序的函數(shù)
函數(shù)21。delay()暫停函數(shù)
函數(shù)22。disable()屏蔽中斷的宏
函數(shù)23。enable()開硬件中斷的宏
函數(shù)24。exec()加載并運(yùn)行其它程序的函數(shù)族
函數(shù)25。farcalloc()從遠(yuǎn)堆中分配內(nèi)存的函數(shù)
函數(shù)26。farfree()從遠(yuǎn)堆中釋放一塊已分配內(nèi)存的函數(shù)
函數(shù)27。farmalloc()從遠(yuǎn)堆中分配內(nèi)存的函數(shù)
函數(shù)28。farrealloc()調(diào)整遠(yuǎn)堆中已分配塊的函數(shù)
函數(shù)29。fclose()關(guān)閉一個(gè)流函數(shù)
函數(shù)30。fcloseall()關(guān)閉打開的流的函數(shù)
函數(shù)31。feof()檢查文件是否結(jié)束的函數(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()打開一個(gè)流函數(shù)
函數(shù)39。FP_OFF()獲取遠(yuǎn)地址偏移量的宏
函數(shù)40。fprintf()傳送輸出到一個(gè)流中的函數(shù)
函數(shù)41。FP_SEG()獲取遠(yuǎn)地址段值的宏
函數(shù)42。fscanf()格式化輸入函數(shù)
函數(shù)43。fseek()移動(dòng)文件指針函數(shù)
函數(shù)44。fwrite()把參數(shù)寫入流中的函數(shù)
函數(shù)45。gcvt()把雙精度數(shù)轉(zhuǎn)化成字符串的函數(shù)
函數(shù)46。geninterrupt()執(zhí)行中斷函數(shù)
函數(shù)47。getc()從流中取字符的宏
函數(shù)48。getch()從鍵盤無回顯地讀取一字符的函數(shù)
函數(shù)49。getchar()從stdin流中讀取一個(gè)字符的函數(shù)
函數(shù)50。getcurdir()讀取指定驅(qū)動(dòng)器的當(dāng)前目錄的函數(shù)
函數(shù)61。getcwd()讀取當(dāng)前目錄的函數(shù)
函數(shù)62。getdate()讀取系統(tǒng)日期函數(shù)
函數(shù)63。getdfree()讀取磁盤空閑空間的函數(shù)
函數(shù)64。getdisk()讀取當(dāng)前磁盤驅(qū)動(dòng)器號(hào)函數(shù)
函數(shù)65。getenv()讀取環(huán)境變量的當(dāng)前值的函數(shù)
函數(shù)66。getimage()將指定區(qū)域的位圖象存入內(nèi)存的函數(shù)
函數(shù)67。getmaxx()返回屏幕上最大的X坐標(biāo)值的函數(shù)
函數(shù)68。getmaxy()返回屏幕上最大的Y坐標(biāo)值的函數(shù)
函數(shù)69。getpixel()讀取像素顏色的函數(shù)
函數(shù)70。getpsp()
函數(shù)71。gets()從標(biāo)準(zhǔn)輸入流stdio中讀取一字符串的函數(shù)
函數(shù)72。gettime()讀取系統(tǒng)時(shí)間的函數(shù)
函數(shù)73。getvect()讀取中斷向量函數(shù)
函數(shù)74。getx()返回當(dāng)前圖形方式下位置的X坐標(biāo)值的函數(shù)
函數(shù)75。gety()返回當(dāng)前圖形方式下位置的Y坐標(biāo)值的函數(shù)
函數(shù)76。imagesize()返回保存圖像緩沖區(qū)大小的函數(shù)
函數(shù)77。initgraph()顯示模式控制函數(shù)(初始化圖形系統(tǒng)函數(shù))
函數(shù)78。inport()從端口中讀入一個(gè)字的函數(shù)
函數(shù)79。inportb()從端口讀入一個(gè)字節(jié)的函數(shù)
函數(shù)80。int86()執(zhí)行中斷函數(shù)(調(diào)用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ù)轉(zhuǎn)換為字符串的函數(shù)
函數(shù)86。kbhit()檢查當(dāng)前按下的鍵的函數(shù)
函數(shù)87。keep()駐留并退出函數(shù)
函數(shù)88。log()
函數(shù)89。log10()
函數(shù)90。_lrotl()將一個(gè)無符號(hào)長(zhǎng)整形數(shù)左循環(huán)移位的函數(shù)
函數(shù)91。_lrotr()將一個(gè)無符號(hào)長(zhǎng)整形數(shù)右循環(huán)移位的函數(shù)
函數(shù)92。lseek()移動(dòng)文件指針函數(shù)
函數(shù)93。ltoa()把長(zhǎng)整形數(shù)轉(zhuǎn)換為字符串的函數(shù)
函數(shù)94。malloc()分配內(nèi)存函數(shù)
函數(shù)95。mkdir()創(chuàng)建目錄函數(shù)
函數(shù)96。mktemp()建立一個(gè)唯一的文件名的函數(shù)
函數(shù)97。MK_FP()設(shè)置一個(gè)遠(yuǎn)指針的宏
函數(shù)98。movedata()拷貝數(shù)據(jù)函數(shù)
函數(shù)99。_open()打開一個(gè)文件進(jìn)行讀寫的函數(shù)
函數(shù)100。open()打開文件進(jìn)行讀寫的函數(shù)
函數(shù)101。outport()輸出一個(gè)字到端口中的函數(shù)
函數(shù)102。outportb()輸出一個(gè)字節(jié)到端口中的函數(shù)
函數(shù)103。outtextxy()在指定位置顯示一字符串的函數(shù)
函數(shù)104。peek()返回指定內(nèi)存中字的函數(shù)
函數(shù)105。peekb()返回指定內(nèi)存中字節(jié)的函數(shù)
函數(shù)106。poke()在指定的內(nèi)存中存儲(chǔ)一個(gè)字的函數(shù)
函數(shù)107。pokeb()在指定的內(nèi)存中存儲(chǔ)一個(gè)字節(jié)的函數(shù)
函數(shù)108。pow()
函數(shù)109。printf()寫格式化輸出到stdout的函數(shù)
函數(shù)110。putch()向屏幕輸出字符的函數(shù)
函數(shù)111。putchar()在stdout上輸出字符的宏
函數(shù)112。putenv()將字符串放入當(dāng)前環(huán)境中的函數(shù)
函數(shù)113。putimage()重新寫屏函數(shù)(輸出一個(gè)位圖象到圖形屏幕上的函數(shù))
函數(shù)114。putpixel()寫像素點(diǎn)函數(shù)
函數(shù)115。puts()輸出一字符串到stdout(標(biāo)準(zhǔn)輸出)的函數(shù)
函數(shù)116。_read()讀文件函數(shù)
函數(shù)117。read()讀文件函數(shù)
函數(shù)118。realloc()重新分配內(nèi)存函數(shù)
函數(shù)119。rectangle()畫一個(gè)矩形的函數(shù)
函數(shù)120。remove()刪除一個(gè)文件的函數(shù)
函數(shù)121。rename()文件改名函數(shù)
函數(shù)122。restorecrtmode()恢復(fù)屏幕視頻模式為調(diào)用initgraph前的設(shè)置的函數(shù)
函數(shù)123。rmdir()刪除目錄函數(shù)
函數(shù)124。_rotl()將一個(gè)無符號(hào)整形數(shù)左循環(huán)移位的函數(shù)
函數(shù)125。_rotr()將一個(gè)無符號(hào)整形數(shù)右循環(huán)移位的函數(shù)
函數(shù)126。scanf()格式化輸入函數(shù)
函數(shù)127。searchpath()按dos路徑查找一個(gè)文件的函數(shù)
函數(shù)128。segread()讀段寄存器函數(shù)
函數(shù)129。setactivepage()設(shè)置圖形輸出活動(dòng)頁的函數(shù)
函數(shù)130。setcolor()設(shè)置當(dāng)前要畫的線顏色的函數(shù)
函數(shù)131。setdisk()設(shè)置當(dāng)前驅(qū)動(dòng)器的函數(shù)
函數(shù)132。setgraphmode()將系統(tǒng)設(shè)置成圖形模式并清屏的函數(shù)
函數(shù)133。setlinestyle()設(shè)置當(dāng)前畫線寬度和類型的函數(shù)
函數(shù)134。settextstyle()顯示字符的當(dāng)前設(shè)置函數(shù)
函數(shù)135。setvect()設(shè)置中斷向量函數(shù)
函數(shù)136。setviewport()建立視口的函數(shù)
函數(shù)137。setvisualpage()設(shè)置可見的圖形頁號(hào)的函數(shù)
函數(shù)138。sin()
函數(shù)139。sprintf()格式化輸出到數(shù)組的函數(shù)
函數(shù)140。strcat()
函數(shù)141。tan()
函數(shù)142。_write()寫文件函數(shù)
函數(shù)143。write()寫文件函數(shù)
原文釋義請(qǐng)到百度文庫(kù)里搜尋字串“C語言常用函數(shù)”后下載
函數(shù)51-60因原注里排序號(hào)碼少編,所以只有133個(gè)常用函數(shù)。
DOC大小是119.5KB
貢獻(xiàn)時(shí)間:2010-09-10
貢獻(xiàn)者:handanlinzhang
求C語言函數(shù)大全
函數(shù)名: abort
功 能: 異常終止一個(gè)進(jìn)程
用 法: void abort(void);
程序例:
#include stdio.h
#include stdlib.h
int main(void)
{
printf("Calling abort()\n");
abort();
return 0; /* This is never reached */
}
函數(shù)名: abs
功 能: 求整數(shù)的絕對(duì)值
用 法: int abs(int i);
程序例:
#include stdio.h
#include math.h
int main(void)
{
int number = -1234;
printf("number: %d absolute value: %d\n", number, abs(number));
return 0;
}
函數(shù)名: absread, abswirte
功 能: 絕對(duì)磁盤扇區(qū)讀、寫數(shù)據(jù)
用 法: int absread(int drive, int nsects, int sectno, void *buffer);
int abswrite(int drive, int nsects, in tsectno, void *buffer);
程序例:
/* absread example */
#include stdio.h
#include conio.h
#include process.h
#include dos.h
int main(void)
{
int i, strt, ch_out, sector;
char buf[512];
printf("Insert a diskette into drive A and press any key\n");
getch();
sector = 0;
if (absread(0, 1, sector, buf) != 0)
{
perror("Disk problem");
exit(1);
}
printf("Read OK\n");
strt = 3;
for (i=0; i80; i++)
{
ch_out = buf[strt+i];
putchar(ch_out);
}
printf("\n");
return(0);
}
函數(shù)名: access
功 能: 確定文件的訪問權(quán)限
用 法: int access(const char *filename, int amode);
程序例:
#include stdio.h
#include io.h
int file_exists(char *filename);
int main(void)
{
printf("Does NOTEXIST.FIL exist: %s\n",
file_exists("NOTEXISTS.FIL") ? "YES" : "NO");
return 0;
}
int file_exists(char *filename)
{
return (access(filename, 0) == 0);
}
函數(shù)名: acos
功 能: 反余弦函數(shù)
用 法: double acos(double x);
程序例:
#include stdio.h
#include math.h
int main(void)
{
double result;
double x = 0.5;
result = acos(x);
printf("The arc cosine of %lf is %lf\n", x, result);
return 0;
}
函數(shù)名: allocmem
功 能: 分配DOS存儲(chǔ)段
用 法: int allocmem(unsigned size, unsigned *seg);
程序例:
#include dos.h
#include alloc.h
#include stdio.h
int main(void)
{
unsigned int size, segp;
int stat;
size = 64; /* (64 x 16) = 1024 bytes */
stat = allocmem(size, segp);
if (stat == -1)
printf("Allocated memory at segment: %x\n", segp);
else
printf("Failed: maximum number of paragraphs available is %u\n",
stat);
return 0;
}
函數(shù)名: arc
功 能: 畫一弧線
用 法: void far arc(int x, int y, int stangle, int endangle, int radius);
程序例:
#include graphics.h
#include stdlib.h
#include stdio.h
#include conio.h
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int stangle = 45, endangle = 135;
int radius = 100;
/* initialize graphics and local variables */
initgraph(gdriver, gmode, "");
/* read result of initialization */
errorcode = graphresult(); /* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());
/* draw arc */
arc(midx, midy, stangle, endangle, radius);
/* clean up */
getch();
closegraph();
return 0;
}
函數(shù)名: asctime
功 能: 轉(zhuǎn)換日期和時(shí)間為ASCII碼
用 法: char *asctime(const struct tm *tblock);
程序例:
#include stdio.h
#include string.h
#include time.h
int main(void)
{
struct tm t;
char str[80];
/* sample loading of tm structure */
t.tm_sec = 1; /* Seconds */
t.tm_min = 30; /* Minutes */
t.tm_hour = 9; /* Hour */
t.tm_mday = 22; /* Day of the Month */
t.tm_mon = 11; /* Month */
t.tm_year = 56; /* Year - does not include century */
t.tm_wday = 4; /* Day of the week */
t.tm_yday = 0; /* Does not show in asctime */
t.tm_isdst = 0; /* Is Daylight SavTime; does not show in asctime */
/* converts structure to null terminated
string */
strcpy(str, asctime(t));
printf("%s\n", str);
return 0;
}
函數(shù)名: asin
功 能: 反正弦函數(shù)
用 法: double asin(double x);
程序例:
#include stdio.h
#include math.h
int main(void)
{
double result;
double x = 0.5;
result = asin(x);
printf("The arc sin of %lf is %lf\n", x, result);
return(0);
}
函數(shù)名: assert
功 能: 測(cè)試一個(gè)條件并可能使程序終止
用 法: void assert(int test);
程序例:
#include assert.h
#include stdio.h
#include stdlib.h
struct ITEM {
int key;
int value;
};
/* add item to list, make sure list is not null */
void additem(struct ITEM *itemptr) {
assert(itemptr != NULL);
/* add item to list */
}
int main(void)
{
additem(NULL);
return 0;
}
函數(shù)名: atan
功 能: 反正切函數(shù)
用 法: double atan(double x);
程序例:
#include stdio.h
#include math.h
int main(void)
{
double result;
double x = 0.5;
result = atan(x);
printf("The arc tangent of %lf is %lf\n", x, result);
return(0);
}
函數(shù)名: atan2
功 能: 計(jì)算Y/X的反正切值
用 法: double atan2(double y, double x);
程序例:
#include stdio.h
#include math.h
int main(void)
{
double result;
double x = 90.0, y = 45.0;
result = atan2(y, x);
printf("The arc tangent ratio of %lf is %lf\n", (y / x), result);
return 0;
}
函數(shù)名: atexit
功 能: 注冊(cè)終止函數(shù)
用 法: int atexit(atexit_t func);
程序例:
#include stdio.h
#include stdlib.h
void exit_fn1(void)
{
printf("Exit function #1 called\n");
}
void exit_fn2(void)
{
printf("Exit function #2 called\n");
}
int main(void)
{
/* post exit function #1 */
atexit(exit_fn1);
/* post exit function #2 */
atexit(exit_fn2);
return 0;
}
函數(shù)名: atof
功 能: 把字符串轉(zhuǎn)換成浮點(diǎn)數(shù)
用 法: double atof(const char *nptr);
程序例:
#include stdlib.h
#include stdio.h
int main(void)
{
float f;
char *str = "12345.67";
f = atof(str);
printf("string = %s float = %f\n", str, f);
return 0;
}
函數(shù)名: atoi
功 能: 把字符串轉(zhuǎn)換成長(zhǎng)整型數(shù)
用 法: int atoi(const char *nptr);
程序例:
#include stdlib.h
#include stdio.h
int main(void)
{
int n;
char *str = "12345.67";
n = atoi(str);
printf("string = %s integer = %d\n", str, n);
return 0;
}
函數(shù)名: atol
功 能: 把字符串轉(zhuǎn)換成長(zhǎng)整型數(shù)
用 法: long atol(const char *nptr);
程序例:
#include stdlib.h
#include stdio.h
int main(void)
{
long l;
char *str = "98765432";
l = atol(lstr);
printf("string = %s integer = %ld\n", str, l);
return(0);
}
c語言常用的函數(shù)有哪些?
#include
assert.h
//設(shè)定插入點(diǎn)
#include
ctype.h
//字符處理
#include
errno.h
//定義錯(cuò)誤碼
#include
float.h
//浮點(diǎn)數(shù)處理
#include
fstream.h
//文件輸入/輸出
#include
iomanip.h
//參數(shù)化輸入/輸出
#include
iostream.h
//數(shù)據(jù)流輸入/輸出
#include
limits.h
//定義各種數(shù)據(jù)類型最值常量
#include
locale.h
//定義本地化函數(shù)
#include
math.h
//定義數(shù)學(xué)函數(shù)
#include
stdio.h
//定義輸入/輸出函數(shù)
#include
stdlib.h
//定義雜項(xiàng)函數(shù)及內(nèi)存分配函數(shù)
#include
string.h
//字符串處理
#include
strstrea.h
//基于數(shù)組的輸入/輸出
#include
time.h
//定義關(guān)于時(shí)間的函數(shù)
#include
wchar.h
//寬字符處理及輸入/輸出
#include
wctype.h
//寬字符分類
標(biāo)準(zhǔn)
C/C++
(同上的不再注釋)
#include
algorithm
//STL
通用算法
#include
bitset
//STL
位集容器
#include
cctype
#include
cerrno
#include
clocale
#include
cmath
#include
complex
//復(fù)數(shù)類
#include
cstdio
#include
cstdlib
#include
cstring
#include
ctime
#include
deque
//STL
雙端隊(duì)列容器
#include
exception
//異常處理類
#include
fstream
#include
functional
//STL
定義運(yùn)算函數(shù)(代替運(yùn)算符)
#include
limits
#include
list
//STL
線性列表容器
#include
map
//STL
映射容器
#include
iomanip
#include
ios
//基本輸入/輸出支持
#include
iosfwd
//輸入/輸出系統(tǒng)使用的前置聲明
#include
iostream
#include
istream
//基本輸入流
#include
ostream
//基本輸出流
#include
queue
//STL
隊(duì)列容器
#include
set
//STL
集合容器
#include
sstream
//基于字符串的流
#include
stack
//STL
堆棧容器
#include
stdexcept
//標(biāo)準(zhǔn)異常類
#include
streambuf
//底層輸入/輸出支持
#include
string
//字符串類
#include
utility
//STL
通用模板類
#include
vector
//STL
動(dòng)態(tài)數(shù)組容器
#include
cwchar
#include
cwctype
using
namespace
std;
C99
增加
#include
complex.h
//復(fù)數(shù)處理
#include
fenv.h
//浮點(diǎn)環(huán)境
#include
inttypes.h
//整數(shù)格式轉(zhuǎn)換
#include
stdbool.h
//布爾環(huán)境
#include
stdint.h
//整型環(huán)境
#include
tgmath.h
//通用類型數(shù)學(xué)宏
C語言常用的函數(shù)有哪些
C語言庫(kù)函數(shù),常用庫(kù)函數(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動(dòng)態(tài)申請(qǐng)內(nèi)存函數(shù)
14、free釋放內(nèi)存函數(shù)
15、abs求絕對(duì)值數(shù)學(xué)函數(shù)
16、sqrt求平方根數(shù)學(xué)函數(shù)
擴(kuò)展資料
語言組成:
1、數(shù)據(jù)類型
C的數(shù)據(jù)類型包括:整型、字符型、實(shí)型或浮點(diǎn)型(單精度和雙精度)、枚舉類型、數(shù)組類型、結(jié)構(gòu)體類型、共用體類型、指針類型和空類型。
2、常量與變量
常量其值不可改變,符號(hào)常量名通常用大寫。
變量是以某標(biāo)識(shí)符為名字,其值可以改變的量。標(biāo)識(shí)符是以字母或下劃線開頭的一串由字母、數(shù)字或下劃線構(gòu)成的序列,請(qǐng)注意第一個(gè)字符必須為字母或下劃線,否則為不合法的變量名。變量在編譯時(shí)為其分配相應(yīng)存儲(chǔ)單元。
3、數(shù)組
如果一個(gè)變量名后面跟著一個(gè)有數(shù)字的中括號(hào),這個(gè)聲明就是數(shù)組聲明。字符串也是一種數(shù)組。它們以ASCII的NULL作為數(shù)組的結(jié)束。要特別注意的是,方括內(nèi)的索引值是從0算起的。
4、指針
如果一個(gè)變量聲明時(shí)在前面使用 * 號(hào),表明這是個(gè)指針型變量。換句話說,該變量存儲(chǔ)一個(gè)地址,而 *(此處特指單目運(yùn)算符 * ,下同。C語言中另有 雙目運(yùn)算符 *) 則是取內(nèi)容操作符,意思是取這個(gè)內(nèi)存地址里存儲(chǔ)的內(nèi)容。指針是 C 語言區(qū)別于其他同時(shí)代高級(jí)語言的主要特征之一。
參考資料來源:百度百科-函數(shù)
有誰能幫我將C語言中所有的函數(shù)及其功能一一列舉一下,不勝感激
復(fù)制
#include
"stdio.h"
{char
s1[]="abcde",s2[]="scasasa";
strcpy(s1,s2);
如果s2長(zhǎng)度大于s1則會(huì)覆蓋掉
如果小于的話只是將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
功
能:
刪除一個(gè)文件
用
法:
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;
}
文章標(biāo)題:c語言函數(shù)大全doc,C語言函數(shù)大全軟件
標(biāo)題來源:http://www.dlmjj.cn/article/hodpsi.html