c语言标准库数学函数 c语言中的标准库函数-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

c语言标准库数学函数 c语言中的标准库函数

c语言常用库函数有哪些

文件stddef.h里包含了标准库的一些常用定义,无论我们包含哪个标准头文件,stddef.h都会被自动包含进来。

铁东网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站设计等网站项目制作,到程序开发,运营维护。创新互联2013年开创至今到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。

这个文件里定义:

类型size_t (sizeof运算符的结果类型,是某个无符号整型);

类型ptrdiff_t(两个指针相减运算的结果类型,是某个有符号整型);

类型wchar_t (宽字符类型,是一个整型,其中足以存放本系统所支持的所有本地环境中的字符集的所有编码值。这里还保证空字符的编码值为0);

符号常量NULL (空指针值);

宏offsetor (这是一个带参数的宏,第一个参数应是一个结构类型,第二个参数应是结构成员名。 offsetor(s,m)求出成员m在结构类型t的变量里的偏移量)。

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 individual 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

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语言标准库数学函数 c语言中的标准库函数
当前路径:http://kswsj.cn/article/dochosj.html

其他资讯