• C语音常用库和函数


    #include <assert.h> //设定插入点 
    #include <ctype.h> //字符处理 
    #include <errno.h> //定义错误码 
    #include <float.h> //浮点数处理 
    #include <fstream.h> //文件输入/输出 
    #include <iomanip.h> //参数化输入/输出 
    #include <iostream.h> //数据流输入/输出 
    #include <limits.h> //定义各种数据类型最值常量 
    #include <locale.h> //定义本地化函数 
    #include <math.h> //定义数学函数 
    #include <stdio.h> //定义输入/输出函数 
    #include <stdlib.h> //定义杂项函数及内存分配函数 
    #include <string.h> //字符串处理 
    #include <strstrea.h> //基于数组的输入/输出 
    #include <time.h> //定义关于时间的函数 
    #include <wchar.h> //宽字符处理及输入/输出 
    #include <wctype.h> //宽字符分类 
    #include <complex> //复数类 
    #include <ios> //基本输入/输出支持 
    #include <iosfwd> //输入/输出系统使用的前置声明 
    #include <iostream> 
    #include <istream> //基本输入流 
    #include <ostream> //基本输出流 
    #include <queue> //STL 队列容器 
    #include <set> //STL 集合容器 
    #include <sstream> //基于字符串的流 
    #include <stack> //STL 堆栈容器 
    #include <stdexcept> //标准异常类 
    #include <streambuf> //底层输入/输出支持 
    #include <string> //字符串类 
    #include <utility> //STL 通用模板类 
    #include <vector> //STL 动态数组容器 
    #include <dos.h>通用dos中断接口函数
    #include <conio.h>)驻留并退出函数

    常用函数

    程序应包含在math.h

    函数类型

    函数形式

    功能

    类型

    数学函数

    abs(int i)

    求整数的绝对值

    int

    fabs(double x)

    返回浮点数的绝对值

    double

    floor(double x)

    向下舍入

    double

    fmod(double x, double y)

    计算x对y的模, 即x/y的余数

    double

    exp(double x)

    指数函数

    double

    log(double x)

    对数函数ln(x)

    double

    log10(double x)

    对数函数log

    double

    labs(long n)

    取长整型绝对值

    long

    modf(double value, double *iptr)

    把数分为指数和尾数

    double

    pow(double x, double y)

    指数函数(x的y次方)

    double

    sqrt(double x)

    计算平方根

    double

    sin(double x)

    正弦函数

    double

    asin(double x)

    反正弦函数

    double

    sinh(double x)

    双曲正弦函数

    double

    cos(double x);

    余弦函数

    double

    acos(double x)

    反余弦函数

    double

    cosh(double x)

    双曲余弦函数

    double

    tan(double x)

    正切函数

    double

    atan(double x)

    反正切函数

    double

    tanh(double x)

    双曲正切函数

    double

    数学函数

    abs(int i)

    求整数的绝对值

    int

    fabs(double x)

    返回浮点数的绝对值

    double

    floor(double x)

    向下舍入

    double

    fmod(double x, double y)

    计算x对y的模, 即x/y的余数

    double

    exp(double x)

    指数函数

    double

    log(double x)

    对数函数ln(x)

    double

    log10(double x)

    对数函数log

    double

    labs(long n)

    取长整型绝对值

    long

    modf(double value, double *iptr)

    把数分为指数和尾数

    double

    pow(double x, double y)

    指数函数(x的y次方)

    double

    sqrt(double x)

    计算平方根

    double

    sin(double x)

    正弦函数

    double

    asin(double x)

    反正弦函数

    double

    sinh(double x)

    双曲正弦函数

    double

    cos(double x);

    余弦函数

    double

    acos(double x)

    反余弦函数

    double

    cosh(double x)

    双曲余弦函数

    double

    tan(double x)

    正切函数

    double

    atan(double x)

    反正切函数

    double

    tanh(double x)

    双曲正切函数

    double

    程序应包含在string.h

    函数类型

    函数形式

    功能

    类型

    字符串函数

    strcat(char *dest,const char *src)

    将字符串src添加到dest末尾

    char

    strchr(const char *s,int c)

    检索并返回字符c在字符串s中第一次出现的位置

    char

    strcmp(const char *s1,const char *s2)
          

      比较字符串s1与s2的大小,并返回s1-s2

    int

    stpcpy(char *dest,const char *src)

    将字符串src复制到dest

    char

    strdup(const char *s)       

    将字符串s复制到最近建立的单元

    char

    strlen(const char *s)       

    返回字符串s的长度

    int

    strlwr(char *s)   

    将字符串s中的大写字母全部转换成小写字母,并返回转换后的字符串

    char

    strrev(char *s)      

      将字符串s中的字符全部颠倒顺序重新排列,并返回排列后的字符串

    char

    strset(char *s,int ch)

    将一个字符串s中的所有字符置于一个给定的字符ch

    char

    strspn(const char *s1,const char *s2)

    扫描字符串s1,并返回在s1和s2中均有的字符个数

    char

    strstr(const char *s1,const char *s2)

    描字符串s2,并返回第一次出现s1的位置

    char

    strtok(char *s1,const char *s2)

    检索字符串s1,该字符串s1是由字符串s2中定义的定界符所分隔

    char

       strupr(char *s)

    将字符串s中的小写字母全部转换成大写字母,并返回转换后的字符串

    char

    程序应包含在ctype.h

    函数类型

    函数形式

    功能

    类型

    字符函数

    isalpha(int  ch) 

    若ch是字母('A'-'Z','a'-'z')返回非0值,否则返回0

    int

        isalnum(int  ch)     

    若ch是字母('A'-'Z','a'-'z')或数字('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是数字('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是空格('  '),水平制表符(' '),回车符(' '), 走纸换行('f'),垂直制表符('v'),换行符(' '),返回非0值,否则返回0

     

     

    int

     

     

    isupper(int  ch)   

    若ch是大写字母('A'-'Z')返回非0值,否则返回0

     

    int

      isxdigit(int  ch) 

    若ch是16进制数('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')

    int

     

    程序应包含在stdio.h

    函数类型

    函数形式

    功能

    类型

    输入输出函数

    getch() 

    从控制台(键盘)读一个字符,不显示在屏幕上

    int

    putch()    

    向控制台(键盘)写一个字符

    int

    getchar()   

    从控制台(键盘)读一个字符,显示在屏幕上

    int

    putchar() 

    向控制台(键盘)写一个字符

    int

    getchar() 

    从控制台(键盘)读一个字符,显示在屏幕上

    int

    getc(FILE  *stream) 

    从流stream中读一个字符,并返回这个字符

    int

    putc(int  ch,FILE  *stream)

    向流stream写入一个字符ch

    int

    getw(FILE  *stream) 

    从流stream读入一个整数,错误返回EOF

    int

    putw(int  w,FILE  *stream)

     向流stream写入一个整数

    int

    fclose(handle)

    关闭handle所表示的文件处理

    FILE *

    fgetc(FILE  *stream) 

    从流stream处读一个字符,并返回这个字符

    int

    fputc(int  ch,FILE  *stream) 

    将字符ch写入流stream中

    int

    fgets(char  *string,int  n,FILE  *stream)

    流stream中读n个字符存入string中

    c har *

    fopen(char *filename,char *type)

    打开一个文件filename,打开方式为type,并返回这个文件指针,type可为以下字符串加上后缀

    FILE *

    fputs(char  *string,FILE  *stream) 

     将字符串string写入流stream中

    int

    fread(void  *ptr,int  size,int  nitems,FILE  *stream)

    从流stream中读入nitems个长度为size的字符串存入ptr中

    int

    fwrite(void  *ptr,int  size,int  nitems,FILE  *stream) 

    向流stream中写入nitems个长度为size的字符串,字符串在ptr中

    int

    fscanf(FILE  *stream,char  *format[,argument,…]) 

    以格式化形式从流stream中读入一个字符串

    int

    fprintf(FILE  *stream,char  *format[,argument,…])

    以格式化形式将一个字符串写给指定的流stream

    int

    scanf(char *format[,argument…])

    从控制台读入一个字符串,分别对各个参数进行赋值,使用BIOS进行输出

    int

    printf(char *format[,argument,…])

     

    发送格式化字符串输出给控制台(显示器),使用BIOS进行输出

    int

  • 相关阅读:
    10、函数介绍、函数参数、函数的返回值
    9、bytes类型,文件处理
    8、集合类型、文件处理
    7、列表类型、元组、字典类型
    6、for循环补充、可变类型与不可变类型、基本操作
    5、while循环与for循环
    4、基本运算符、if语法
    3、变量、常量、基本数据类型
    爬虫(一)
    小技能(二)
  • 原文地址:https://www.cnblogs.com/xitang/p/4174985.html
Copyright © 2020-2023  润新知