当前位置:首页 » 编程语言 » 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