C头文件之<cstring>
(string.h)
这个文件夹主要是定义了几个对字符串和数组进行操作的函数。功能很强大。下面是重要函数:
- strcpy、strncpy
- strcpy,strncpy
- 这两个函数是对字符串的复制,很常用。
- memcpy
- 函数原型:void * memcpy ( void * destination, const void * source, size_t num );。主要用于数组指定的内存之间的复制,而不是字符串之间。将source指定的内存前num个字节复制到destination指定的内存的千numge字节。
- memset
- 函数原型:void * memset ( void * ptr, int value, size_t num );主要用于数组的初始化。将ptr指定的内存的前num个字节初始化为value。可以用于数组初始化,不用遍历数组赋值了。
/* memset example */
#include <stdio.h>
#include <string.h> int main ()
{
char str[] = "almost every programmer should know memset!";
memset (str,'-',sizeof(str));
puts (str);
return ;
}/*OutPut*/
----------------------------------------------------------
C头文件之<cstring>的更多相关文章
- 头文件string.h,cstring与string
string.h string.h是一个C标准头文件,所有的C标准头文件都形如name.h的形式,通过#include <string.h>可以导入此头文件.之后我们就可以在程序中使用st ...
- 头文件 string.h cstring string 区别
1.#include <cstring> //不可以定义string s:可以用到strcpy等函数using namespace std; #include <stri ...
- cstring头文件函数解析
原创作品,转载请注明来源:http://www.cnblogs.com/shrimp-can/p/5643829.html 在使用由字符数组或指针组成的字符串的时候,要用到一些函数,这些函数通常包含在 ...
- CString的头文件
CString的头文件:#include <atlstr.h>
- vs中CString的用法,以及所需的头文件
转载:https://blog.csdn.net/shizhandong50/article/details/13321505 1.CString类型的头文件#include <afx.h> ...
- c/c++头文件_string
string, cstring, string.h 一.string头文件 主要包含一些字符串转换的函数 // sto* NARROW CONVERSIONS// sto* WIDE CONVERSI ...
- C++笔记(二)------ 头文件
类似#include<string>与#include<string.h>等头文件的区别 标准的C++头文件没有.h扩展名,带有.h的头文件一般都是C语言的.例如#includ ...
- 高级c++头文件bits/stdc++.h
用这种方法声明头文件只需两行代码 #include<bits/stdc++.h> using namespace std; 这个头文件包含以下等等C++中包含的所有头文件: #includ ...
- 2.头文件<bits/stdc++.h>
用这种方法声明头文件只需两行代码 #include<bits/stdc++.h> using namespace std; 这个头文件包含以下等等C++中包含的所有头文件: #inclu ...
随机推荐
- excel if判断时间段早晚班
=IF(OR(HOUR(B3)={9,10,11,12,13,14,15,16,17,18}),"早班","晚班")
- find type d 命令批量删除禁用
[root@qike ~]# find /usr/local/sbin/ -type d /usr/local/sbin//usr/local/sbin/2/usr/local/sbin/g/u ...
- 边工作边刷题:70天一遍leetcode: day 81
Encode and Decode Strings 要点:题的特点:不是压缩,而是encode为字节流.所以需要找delimiter来分割每个word,但是delimiter可能是字符本身,所以可以用 ...
- codeforces 487C C. Prefix Product Sequence(构造+数论)
题目链接: C. Prefix Product Sequence time limit per test 1 second memory limit per test 256 megabytes in ...
- 保存带有emoji的文本报错解决方案
今天偶然遇到一个错误,就是保存文本的时候带有了emoji表情,报错了 java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x8A\ ...
- Java Executor并发框架(二)剖析ThreadPoolExecutor运行过程
上一篇从整体上介绍了Executor接口,从上一篇我们知道了Executor框架的最顶层实现是ThreadPoolExecutor类,Executors工厂类中提供的newScheduledThrea ...
- 对访问修饰关键字public, protected, internal and private的说明
对访问修饰关键字public, protected, internal and private的说明1.msdn: Internal types or members are accessible o ...
- javascript边角知识
1.组织默认事件 阻止默认事件,h5默认的input type='date'在某些浏览器和android设备上没有效果,这时要调用h5+的时间选择器,但是要组织input默认的click事件,代码如下 ...
- 普通请求和ajax请求的区别
普通请求和ajax请求的区别? 下面的action返回一个json文件,文件内容为sts.*,data1
- Silverlight中使用MVVM:DataGrid中触发Button的Click事件
方法1.使用RelativeSource向上查找DataContext中的命令,但是需要注意的是命令绑定需要写全 类似: DataContext.ReLoadCommand<Button Gri ...