Linux C学习笔记 —— 字符串处理函数(string.h)
来源:互联网 发布:java webservice 编辑:程序博客网 时间:2024/06/05 04:41
char *strcpy(char *s1, const char *s2) 将字符串s2复制到字符数组s1中
char *strncpy(char *s1, const char *s2, size_t n) 将字符串s2开始的n个字节复制到字符数组s1中
char *strcat(char *s1, const char *s2) 将字符串s2追加到字符数组s1中的字符串后
char *strncat(char *s1, const char *s2, size_t n) 将字符串s2开始的n个字节追加到字符数组s1中的字符串后
除strncpy()函数外,这几个函数都会将数组s1后未用到的数组元素置为0。s1必须有足够的空间存储字符串s2或追加字符串s2。
#include <stdio.h>
#include <string.h>
#define LENGTH 20
int main()
{
char a[LENGTH];
const char *s = "ABCDEFG";
strcpy(a, s);
puts(a);
strncpy(a, s, 4);
puts(a);
strcat(a, s);
puts(a);
strncat(a ,s, 4);
puts(a);
return 0;
}
阅读全文
0 0
- Linux C学习笔记 —— 字符串处理函数(string.h)
- Linux C学习笔记 —— 字符串转换函数(stdlib.h)
- 字符串处理函数(string.h)
- 字符串处理函数(string.h)
- C语言笔记——头文件string.h中内置的常用字符串操作函数
- C下常用字符串处理函数<string.h>
- Linux C学习笔记 —— 字符处理库函数(ctype.h)
- C Primer Plus学习 三十三 string.h 其他字符串函数
- C/C++<string.h>字符串函数
- C标准库源码解剖(4):字符串处理函数string.h和wchar.h
- C标准库源码解剖(5):字符串处理函数string.h和wchar.h(续)
- C标准库源码解剖(6):字符串处理函数string.h和wchar.h(续)
- C++库函数---<string.h>字符串处理函数
- 字符串处理函数string.h和wchar.h
- 字符串处理函数string.h和wchar.h(续1)
- 字符串处理函数string.h和wchar.h(续2)
- Linux C编程--string.h函数解析
- C++ string函数 与 C字符串处理函数(整理)
- IT时代的投资
- Oracle12C用户创建、授权、登录
- JSP应用
- [Nginx]Nginx简单使用(一)
- 3378 数据结构实验之查找六:顺序查找
- Linux C学习笔记 —— 字符串处理函数(string.h)
- Ext操作DOM元素之insertHtml
- 【vim】插件管理及代码智能提示与补全环境的配置
- 使用Atom快速打造好用的Markdown编辑器
- MATLAB 制作gif动态图
- RedHat Enterprise 6.4 安装
- 扩展虚拟机VM的磁盘空间(LVM)
- JVM调优
- redis开机启动与centos6开机启动配置