glibc源码-标准库的一些函数

本文探讨了glibc 2.32版本中stdio.h和string.h的标准库函数,如gets、fgets、strcpy和strncpy。指出了strcpy的安全隐患,如数组越界和未校验输入。strncpy的处理方式是在目标字符串长度限制下复制并添加终止符,但无法处理内存重叠情况。
摘要由CSDN通过智能技术生成

glibc版本:2.32
IDE:vscode

个人认为比较常用的,可以看看源码的函数,总结下:

stdio.h

路径:\glibc\libio\stdio.h

函数原型 功能
输入
int fprintf (FILE *__restrict __stream, const char *__restrict __format, ...); 格式化输出到文件
int printf (const char *__restrict __format, ...); 格式化输出到标准输出
int sprintf (char *__restrict __s, const char *__restrict __format, ...) __THROWNL; 格式化输出到字符串中
int snprintf (char *__restrict __s, size_t __maxlen, const char *__restrict __format, ...) __THROWNL __attribute__ ((__format__ (__printf__, 3, 4))); 格式化输出指定长度内容到字符串中
输出
int fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __wur; 从文件中读取格式化字符
int scanf (const char *__restrict __format, ...) __wur; 从标准输入读取格式化字符
int sscanf (const char *__restrict __s, const char *__restrict __format, ...) __THROW; 从字符串中读取格式化字符
获取字符
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值