C++中字符串与字符串函数的使用
引用字符串或者使用字符串函数
注意,在C++中,#include<string>
与#include<ctring>
和#include<string.h>
是不一样的。
-
使用C中的字符串函数比如strlen(),需要引入的是
#include<ctring>
或者#include<string.h>
-
使用字符串变量比如
string str = "abc"
,需要引入的是#include<string>
引用字符串或者使用字符串函数
注意,在C++中,#include<string>
与#include<ctring>
和#include<string.h>
是不一样的。
使用C中的字符串函数比如strlen(),需要引入的是#include<ctring>
或者#include<string.h>
使用字符串变量比如string str = "abc"
,需要引入的是#include<string>