當前位置:首頁 » 編程語言 » c語言所有標准庫函數
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言所有標准庫函數

發布時間: 2023-03-29 00:12:59

c語言常用庫函數有哪些

C語言的標准庫函數有數百個,分布在不同的庫文件中,目前絕大多數系統和程序肯定兼容的是C99標准,但2011年已經發布了更新的版本,有些遺留系統不一定支持最新的特性。
不同函數應用場合不一樣,說不說哪些更常用,就看你所做工作的性質了。
通常來說,至少在基礎編程時,stdio中的輸入輸出(可能是控制台的、也可能是文件的)、stdlib中的各種通用工具(如分配堆內存)、string中的字元串處理、time中的日期時間處理、math中的數學函數都算是比較常用的。

❷ C語言中的標准函數有哪些

C語言輸入輸出函數有很多,標准I/O函數中包含了如下幾個常用的函數:
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.但是從輸入流中讀取字元時又涉及到緩沖的問題,所以並不是在屏幕中敲上一個字元程序就會運行,一般是通過在屏幕上敲上回車鍵,然後將回車前的字元串放在緩沖區中,getchar就是在緩沖區中一個一個的讀字元.當然也可以在while循環中指定終止字元,如下面的語句: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是存放讀入的字元數組指針,num是最大允許的讀入字元數,fp是文件指針.fgets的功能是讀一行字元,該行的字元數不大於num-1.因為fgets函數會在末尾加上一個空字元以構成一個字元串.另外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按照指定格式從文件中出讀出數據,並賦值到參數列表中.
int
fprintf(FILE
*fp,
char
*format,
輸出列表)
fprintf將格式化數據寫入流式文件中.
數據塊讀寫函數
fread
(buffer,size,count,fp);
fwrite(buffer,size,count,fp);
參數說明:
buffer:是一個指針。
對fread
來說,它是讀入數據的存放地址。
對fwrite來說,是要輸出數據的地址(均指起始地址)。
size:
要讀寫的位元組數。
count:
要進行讀寫多少個size位元組的數據項。
fp:
文件型指針。

❸ 簡述C語言標准庫函數strcpy功能和格式

strcpy是C語言標准庫函數中的字元串復制函數。它的功能是將源字元串(即第二個參數)復制到目標字元串(即第一個參數)中。

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

其中,

  • dest是指向目標字元串的指針,接收復制的字元串。

  • src是指向源字元串的指針,要被復制的字元串。

  • strcpy函數返回指向目標字元串的指針。

    注意:由於目標字元串必須有足夠的空間來存儲源字元串,因此應該確保目標字元串具有足夠的空間。否則,可能會發生內存泄漏或緩沖區溢出。

❹ c語言常用庫函數有哪些

最低0.27元/天開通網路文庫會員,可在文庫查看完整內容>
原發布者:shimingtime
附錄CC語言常用的庫函數庫函數並不是C語言的一部分,它是由編譯系統根據一般用戶的需要編制並提供給用戶使用的一組程序。每一種C編譯系統都提供了一批庫函數,不同的編譯系統所提供的庫函數的數目和函數名以及函數功能是不完全相同的。ANSIC標准提出了一批建議提供的標准庫函數。它包括了目前多數C編譯系統所提供的庫函數,但也有一些是某些C編譯系統未曾實現的。考慮到通用性,本附錄列出ANSIC建議的常用庫函數。由於C庫函數的種類和數目很多,例如還有屏幕和圖形函數、時間日期函數、與系統有關的函數等,每一類函數又包括各種功能的函數,限於篇幅,本附錄不能全部介紹,只從教學需要的角度列出最基本的。讀者在編寫C程序時可根據需要,查閱有關系統的函數使用手冊。1.數學函數使用數學函數時,應該在源文件中使用預編譯命令:#include或#include"math.h"2.字元函數在使用字元函數時,應該在源文件中使用預編譯命令:#include或#include"ctype.h"3.字元串函數使用字元串中函數時,應該在源文件中使用預編譯命令:#include或#include"string.h"4.輸入輸出函數在使用輸入輸出函數時,應該在源文件中使用預編譯命令:#include或#include"stdio.h"5.動態存儲分配函數在使用動態存儲分配函數時,應該在源文件中使用預編譯命令:#include或#include"stdlib.h"6.其他函數有些函數由於不便歸入某一類,所以單獨列出。使用這些

❺ c語言有多少庫函數

1)如果是在校期間為了等級考試,則記住基本的的輸入輸出函數,文件操作函數,常用數學處理函數,字元串操作函數,內存操作函數就差不多啦。
2)如果從事編程工作,需要記住的就多啦,而且和從事的編程方向有關。初期先有個函數列表,知道哪些功能已經提供,自己不需要總是造輪子,用的時候查查函數參考手冊。用的多啦,自然就記得多啦,寫起程序來也得心應手。
3)好的程序員記住的函數實際是非常多的,只是不刻意去記,熟能生巧而已。

❻ C語言中對字元串進行操作的標准庫函數有哪些

1)字元串操作
strcpy(p, p1) 復制字元串
strncpy(p, p1, n) 復制指定長度字元串
strcat(p, p1) 附加字元串
strncat(p, p1, n) 附加指定長度字元串
strlen(p) 取字元串長度
strcmp(p, p1) 比較字元串
strcasecmp忽略大小寫比較字元串
strncmp(p, p1, n) 比較指定長度字元串
strchr(p, c) 在字元串中查找指定字元
strrchr(p, c) 在字元串中反向查找
strstr(p, p1) 查找字元串
strpbrk(p, p1) 以目蘆迅標字元串的所有字元作為集合,在當前字元串查找該集合的任一元素
strspn(p, p1) 以目標字元串的所有字元作為集合,在當前字元串查找不屬於該集合的任一元素的偏移
strcspn(p, p1) 以目標字元串的所有字元作為集合,在當前字元串查找屬於該集合的任一元素的偏移
* 具有指定長度的字元串處理函數在已處理的字元串之後填姿嘩祥補零結尾符

2)字元串到數值類型的轉換
strtod(p, ppend) 從字元串 p 中轉換 double 類型數值,並將後續的字元串指針存儲到 ppend 指向的 char* 類型存儲。
strtol(p, ppend, base) 從字元串 p 中轉換 long 類型整型數值,base 顯式設置轉換的整型進制,設置為 0 以根據特定格式判斷所用進制,0x, 0X 前綴以解釋為十六進制格式整型,0 前綴以解釋為八進制格式整型
atoi(p) 字元串轉換到 int 整型
atof(p) 字元串轉換到 double 符點數
atol(p) 字元串轉換到 long 整型

3)字元檢查
isalpha() 檢查是否為字母字元
isupper() 檢查是否為大寫字母字元
islower() 檢查是否為小寫字母字元
isdigit() 檢查是否為數字
isxdigit() 檢查是否為十六進制數字表示的有效字元
isspace() 檢查是否為空格類型字元
iscntrl() 檢查是否為控制字元
ispunct() 檢查是否為標點符號
isalnum() 檢查是否為字母和數字
isprint() 檢查跡搏是否是可列印字元
isgraph() 檢查是否是圖形字元,等效於 isalnum() | ispunct()

❼ 什麼是C語言標准函數庫平常用的哪些函數屬於標准函數庫

你會發現,有一些頭文件(比如stdlib.h,stdio.h)每一個編譯器都有,而裡面的函數(如printf,malloc)每一個編譯器都支持。這些函數組成的集合就是標准函數庫。平常用的函數基本都屬於標准函數庫。
ANSI對此是有規定的

❽ 在C中,什麼是標准庫函數

在C語言程序設計里,C 標准函數庫(C Standard library) 是所有符合標準的頭文件(head file)的集合,以及常用的函數庫實現程序,例如I/O 輸入輸出和字元串控制。不像COBOL、Fortran和PL/I等編程語言,在 C 語言的工作任務里不會包含嵌入的關鍵字,所以幾乎所有的 C 語言程序都是由標准函數庫的函數來創建的。

每一個函數的名稱與特性會被寫成一個電腦文件,這個文件就稱為頭文件,但是實際的函數實現是被分存到函數庫文件里。頭文件的命名和領域是很常見的,但是函數庫的組織架構也會因為不同的編譯器而有所不同。標准函數庫通常會隨附在編譯器上。因為 C 編譯器常會提供一些額外的非ANSI C函數功能,所以某個隨附在特定編譯器上的標准函數庫,對其他不同的編譯器來說,是不兼容的。

❾ C語言中的標准函數有哪些

在最新的 C99 標准中,只有以下兩種定義方式是正確的:
int main( void ) /* 無參數形式 */
{

return 0;
}
int main( int argc, char *argv[] ) /* 帶參數形式 */
{

return 0;
}
int指明了main()函數的返回類型,函數名後面的圓括弧一般包含傳遞給函數的信息。void表示沒有給函數傳遞參數。關於帶參數的形式,我們等會討論。
瀏覽老版本的C代碼,將會發現程序常常以。
main()
這種形式開始。C90標准允許這種形式,但是C99標准不允許。因此即使你當前的編譯器允許,也不要這么寫。
你還可能看到過另一種形式。
void main()
有些編譯器允許這種形式,但是還沒有任何標准考慮接受它。C++ 之父 Bjarne Stroustrup 在他的主頁上的 FAQ 中明確地表示:void main( ) 的定義從來就不存在於 C++ 或者 C 。所以,編譯器不必接受這種形式,並且很多編譯器也不允許這么寫。

❿ C 語言標准庫函數

C語言標准庫函數

標准io函數
Standard C I/O
clearerr() clears errors
fclose() close a file
feof() true if at the end-of-file
ferror() checks for a file error
fflush() writes the contents of the output buffer
fgetc() get a character from a stream
fgetpos() get the file position indicator
fgets() get a string of characters from a stream
fopen() open a file
fprintf() print formatted output to a file
fputc() write a character to a file
fputs() write a string to a file
fread() read from a file
freopen() open an existing stream with a different name
fscanf() read formatted input from a file
fseek() move to a specific location in a file
fsetpos() move to a specific location in a file
ftell() returns the current file position indicator
fwrite() write to a file
getc() read a character from a file
getchar() read a character from STDIN
gets() read a string from STDIN
perror() displays a string version of the current error to STDERR
printf() write formatted output to STDOUT
putc() write a character to a stream
putchar() write a character to STDOUT
puts() write a string to STDOUT
remove() erase a file
rename() rename a file
rewind() move the file position indicator to the beginning of a file
scanf() read formatted input from STDIN
setbuf() set the buffer for a specific stream
setvbuf() set the buffer and size for a specific stream
sprintf() write formatted output to a buffer
sscanf() read formatted input from a buffer
tmpfile() return a pointer to a temporary file
tmpnam() return a unique filename
ungetc() puts a character back into a stream
vprintf, vfprintf, vsprintf write formatted output with variable argument lists

標准字元/字元串處理函數
atof() converts a string to a double
atoi() converts a string to an integer
atol() converts a string to a long
isalnum() true if alphanumeric
isalpha() true if alphabetic
iscntrl() true if control character
isdigit() true if digit
isgraph() true if a graphical character
islower() true if lowercase
isprint() true if a printing character
ispunct() true if punctuation
isspace() true if space
isupper() true if uppercase character
isxdigit() true if a hexidecimal character
memchr() searches an array for the first occurance of a character
memcmp() compares two buffers
memcpy() copies one buffer to another
memmove() moves one buffer to another
memset() fills a buffer with a character
strcat() concatenates two strings
strchr() finds the first occurance of a character in a string
strcmp() compares two strings
strcoll() compares two strings in accordance to the current locale
strcpy() copies one string to another
strcspn() searches one string for any characters in another
strerror() returns a text version of a given error code
strlen() returns the length of a given string
strncat() concatenates a certain amount of characters of two strings
strncmp() compares a certain amount of characters of two strings
strncpy() copies a certain amount of characters from one string to another
strpbrk() finds the first location of any character in one string, in another string
strrchr() finds the last occurance of a character in a string
strspn() returns the length of a substring of characters of a string
strstr() finds the first occurance of a substring of characters
strtod() converts a string to a double
strtok() finds the next token in a string
strtol() converts a string to a long
strtoul() converts a string to an unsigned long
strxfrm() converts a substring so that it can be used by string comparison functions
tolower() converts a character to lowercase
toupper() converts a character to uppercase

標准數學函數
abs() absolute value
acos() arc cosine
asin() arc sine
atan() arc tangent
atan2() arc tangent, using signs to determine quadrants
ceil() the smallest integer not less than a certain value
cos() cosine
cosh() hyperbolic cosine
div() returns the quotient and remainder of a division
exp() returns "e" raised to a given power
fabs() absolute value for floating-point numbers
floor() returns the largest integer not greater than a given value
fmod() returns the remainder of a division
frexp() decomposes a number into scientific notation
labs() absolute value for long integers
ldexp() computes a number in scientific notation
ldiv() returns the quotient and remainder of a division, in long integer form
log() natural logarithm
log10() natural logarithm, in base 10
modf() decomposes a number into integer and fractional parts
pow() returns a given number raised to another number
sin() sine
sinh() hyperbolic sine
sqrt() square root
tan() tangent
tanh() hyperbolic tangent

標准時間/日期函數
asctime() a textual version of the time
clock() returns the amount of time that the program has been running
ctime() returns a specifically formatted version of the time
difftime() the difference between two times
gmtime() returns a pointer to the current Greenwich Mean Time
localtime() returns a pointer to the current time
mktime() returns the calendar version of a given time
strftime() returns indivial elements of the date and time
time() returns the current calendar time of the system

標准內存管理函數
calloc() allocates a two-dimensional chunk of memory
free() makes memory available for future allocation
malloc() allocates memory
realloc() changes the size of previously allocated memory

其它標准函數
abort() stops the program
assert() stops the program if an expression isn';t true
atexit() sets a function to be called when the program exits
bsearch() perform a binary search
exit() stop the program
getenv() get enviornment information about a variable
longjmp() start execution at a certain point in the program
qsort() perform a quicksort
raise() send a signal to the program
rand() returns a pseudorandom number
setjmp() set execution to start at a certain point
signal() register a function as a signal handler
srand() initialize the random number generator
system() perform a system call
va_arg() use variable length parameter lists