strlcpy() 函数
size_t strlcpy(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
size_t n = siz;
/* Copy as many bytes as will fit */
if (n != 0)
{
while (--n != 0)
{
if ((*d++ = *s++) == '\0')
break;
}
}
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0)
{
if (siz != 0)
*d = '\0';
/* NUL-terminate dst */
while (*s++)
;
}
return(s - src - 1); /* count does not include NUL */
}
strlcpy() 函数的更多相关文章
- C语言中函数strcpy ,strncpy ,strlcpy的用法【转】
转自:http://blog.chinaunix.net/uid-20797562-id-99311.html strcpy ,strncpy ,strlcpy的用法好多人已经知道利用strncpy替 ...
- C语言中函数strcpy ,strncpy ,strlcpy的用法
strcpy ,strncpy ,strlcpy的用法 好多人已经知道利用strncpy替代strcpy来防止缓冲区越界. 但是如果还要考虑运行效率的话,也许strlcpy是一个更好的方式. 1. s ...
- (C)strcpy ,strncpy与strlcpy
1. 背景 好多人已经知道利用strncpy替代strcpy来防止缓冲区越界. 但是如果还要考虑运行效率的话,也许strlcpy是一个更好的方式. 2. strcpy strcpy 是依据 /0 作为 ...
- (C)strcpy ,strncpy和strlcpy的基本用法
好多人已经知道利用strncpy替代strcpy来防止缓冲区越界. 但是如果还要考虑运行效率的话,也许strlcpy是一个更好的方式. 1. strcpy strcpy 是依据 /0 作为结束判断的, ...
- Linux C中strcpy , strncpy , strlcpy 的区别
strcpy ,strncpy ,strlcpy的用法 好多人已经知道利用strncpy替代strcpy来防止缓冲区越界. 但是如果还要考虑运行效率的话,也许strlcpy是一个更好的方式. 1. s ...
- 查看文章strncpy()功能更好的文章
strncpy()功能 原型:extern char *strncpy(char *dest, char *src, int n); 使用方法:#include <string.h> ...
- linux内核驱动中对字符串的操作【转】
转自:http://www.360doc.com/content/12/1224/10/3478092_255969530.shtml Linux内核中关于字符串的相关操作,首先包含头文件: #inc ...
- Linux驱动之USB(个人)
USB概述 <USB简介> a:背景 USB是Universal Serial Bus的缩写,是一种全新的,双向同步传输的,支持热插拔的 ...
- Strlcpy和strlcat——一致的、安全的字符串拷贝和串接函数【转】
转自:http://blog.csdn.net/kailan818/article/details/6731772 英文原文: http://www.gratisoft.us/todd/papers/ ...
随机推荐
- 从0.5开始学Java 零
作为新世纪的码农,掌握多门语言是必须的. 我先从java学起,工作又是做c# ,现在辞职了想重新捡回java的技术,所以写一个长篇 来给自己复习 ,题目就叫做从0.5开始学java. 核心内容就是 一 ...
- 手动搭建SSI框架
SSI框架为struts.spring.ibatis,在该框架中,使用ibatis作为数据持久层,其中ibatis使用最新版本mybatis3. 注:本文使用版本:struts-2.3.4.sprin ...
- 二十三、oracle pl/sql分类三 包
包用于在逻辑上组合过程和函数,它由包规范和包体两部分组成.1).我们可以使用create package命令来创建包,如:i.创建一个包sp_packageii.声明该包有一个过程update_sal ...
- C语言函数参数的传递详解
一.三道考题 开讲之前,我先请你做三道题目.(嘿嘿,得先把你的头脑搞昏才行--唉呀,谁扔我鸡蛋?)考题一,程序代码如下:void Exchg1(int x, int y){ int tmp; ...
- Atitit 版本管理----分支管理
Atitit 版本管理----分支管理 版本管理系统"(Version Control System Branch/tag在一个功能选项中,在使用中很容易产生混淆. 分支(Branch)管理 ...
- 自定义控件学习之canvas和paint相关知识点学习
1,继承自view,实现ondraw方法: 初始化画笔,TextPaint paint,并设置画笔属性: paint.setFlags(Paint.ANTI_ALIAS_FLAG):画笔抗锯齿. pa ...
- URAL 1525 Path
#include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> us ...
- hdu1012
#include<iostream>#include<stdio.h> using namespace std; int jiechen(int n){ int i; ...
- 【转载】FaceBook - How to add a Privacy Policy to your Apps?
When you read through the Facebook Platform Policies, you'll notice that every Facebook App that sto ...
- arttemplate函数摘录
对artTemplate函数摘录,希望可以用到自己平时的工作中去 var toString = function (value, type) { if (typeof value !== 'strin ...