zoukankan      html  css  js  c++  java
  • 记录一些Linux C的常用库函数

    我已经受不了每次用的时候去百度了,还百度不出来。。。。。

    【数字字符串转换篇】

    atof - convert a string to a double

    #include <stdlib.h>

    double atof(const char *nptr);

    atoi, atol, atoll, atoq - convert a string to an integer

    #include <stdlib.h>

    int atoi(const char *nptr);
    long atol(const char *nptr);
    long long atoll(const char *nptr);
    long long atoq(const char *nptr);

    strtod, strtof, strtold - convert ASCII string to floating-point number

    #include <stdlib.h>

    double strtod(const char *nptr, char **endptr);
    float strtof(const char *nptr, char **endptr);
    long double strtold(const char *nptr, char **endptr);

    strtoul, strtoull, strtouq - convert a string to an unsigned long integer

    #include <stdlib.h>

    unsigned long int strtoul(const char *nptr, char **endptr, int base);

    unsigned long long int strtoull(const char *nptr, char **endptr, int base);

    gcvt - convert a floating-point number to a string

    #include <stdlib.h>

    char *gcvt(double number, size_t ndigit, char *buf);

    【字符串操作篇】

    strtok, strtok_r - extract tokens from strings

    #include <string.h>

    char *strtok(char *str, const char *delim);

    char *strtok_r(char *str, const char *delim, char **saveptr);

    strcmp, strncmp - compare two strings

    #include <string.h>

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

    int strncmp(const char *s1, const char *s2, size_t n);

    strcasecmp, strncasecmp - compare two strings ignoring case

    #include <strings.h>

    int strcasecmp(const char *s1, const char *s2);

    int strncasecmp(const char *s1, const char *s2, size_t n);

    【网络字节篇】

    htonl, htons, ntohl, ntohs - convert values between host and network byte order

    #include <arpa/inet.h>

    uint32_t htonl(uint32_t hostlong);

    uint16_t htons(uint16_t hostshort);

    uint32_t ntohl(uint32_t netlong);

    uint16_t ntohs(uint16_t netshort);

    【输出篇】

    printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf, vsnprintf - formatted output conversion

    #include <stdio.h>

    int printf(const char *format, ...);
    int fprintf(FILE *stream, const char *format, ...);
    int sprintf(char *str, const char *format, ...);
    int snprintf(char *str, size_t size, const char *format, ...);

    #include <stdarg.h>

    int vprintf(const char *format, va_list ap);
    int vfprintf(FILE *stream, const char *format, va_list ap);
    int vsprintf(char *str, const char *format, va_list ap);
    int vsnprintf(char *str, size_t size, const char *format, va_list ap);

  • 相关阅读:
    杂记:Linux下gcc升级
    杂记:OSX下编译安装最新版RedisDesktopMmanager
    查漏补缺:Vector中去重
    Mac下使用VScode进行C/C++开发
    添砖加瓦:几种常见的数据摘要算法(MD5、CRC32、SHA1和SHA256)
    添砖加瓦:snappy无损压缩算法
    杂记:OSX 安装openssl
    码海拾遗:内存四区
    Luogu 4284 [SHOI2014]概率充电器
    Luogu 4473 [国家集训队]飞飞侠
  • 原文地址:https://www.cnblogs.com/jieyuefeng/p/3424897.html
Copyright © 2011-2022 走看看