#include<string.h>、#include<cstring>与#include<string>的区别
来源:互联网 发布:sql 取日期的年月日 编辑:程序博客网 时间:2024/04/26 06:10
前言:今天在写C++小demo的时候,犯了个错误,引入了string.h,导致cout报错;于是查了下,C++标准库文件没有后缀.h
string.h
- string.h是C语言里面关于字符数组的函数定义的头文件,常用函数有strlen、strcmp、strcpy等等,更详细的信息可以自己查看(面向过程)
cstring
- CString常用于MFC编程中,是属于MFC的类,如从对话框中利用GetWindowText得到的字符串就是CString类型,CString定义在afx.h头文件中。CString为Visual C++中最常用的字符串类,继承自CSimpleStringT类,主要应用在MFC和ATL编程中,所以使用CString时要包含afx.h文件。
string
- string是C++标准库(STL)中的类型,它是定义的一个类,定义在string头文件中。里面包含了对字符串的各种常用操作,它较char*的优势是内容可以动态拓展,以及对字符串操作的方便快捷,用+号进行字符串的连接是最常用的操作。
其他参考
1、<> 尖括号”“双引号包含头文件的区别是搜索路径不同
<>尖括号搜索系统库路径
“”双引号搜索当前路径,当前路径没有搜索系统库路径
2、string头文件在c++里有三种含义
string c++标准库提供的string类
string.h c标准库提供的字符串函数
cstring c++对标准c字符串处理函数的c++增强
总结:注意要根据自己需要引入相应的头文件
0 0
- #include<string.h>、#include<cstring>与#include<string>的区别
- include <cstring>,include <string> include <string.h>的区别
- #include <string.h> 、<cstring>、<string> 的区别
- #include<string>与#include<string.h>的区别
- #include<string>与#include<string.h>的区别
- #include<string>与#include<string.h>的区别
- C++中#include<string>与#include<string.h>的区别
- #include<string>与#include<string.h>的区别
- #include<string>与#include<string.h>的区别
- #include<string>与#include<string.h>的区别
- #include<string>与#include<string.h>的区别
- #include <string> <string.h> <cstring> 三者的区别
- #include<iostream>与#include<iostream.h>以及#inclue<string> 和 #include<string.h>的区别
- #include<iostream>与#include<iostream.h>以及#inclue<string> 和 #include<string.h>的区别
- #include<iostream>与#include<iostream.h>及#inclue <string> 和 #include <string.h>的区别
- #include<iostream>与#include<iostream.h>以及#inclue<string> 和 #include<string.h>的区别
- #include<string> 与#include<string.h>
- #include<string>和#include<string.h>的区别
- 最短路径 Dijkstra(迪杰斯特拉)
- JavaScript学习之路04_对象
- 特殊浮点数1.#IND 1.#INF的判断
- 并查集模板
- 系统周期性计划任务
- #include<string.h>、#include<cstring>与#include<string>的区别
- Android 中的adapter和作用以及常见的adapter
- iOS NSDate
- 文章标题南大软院大神养成计划--day06
- JNI基本概念
- android Listview显示不同的item遇到的问题
- CSS基础
- Office 365 Service Communications API operations--Get Services
- gzip: stdin: unexpected end of file tar: Unexpected EOF in archive tar: Unexpected EOF in archive ta