cstring头文件里的函数怎么用
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cstring头文件里的函数怎么用相关的知识,希望对你有一定的参考价值。
using ::memcpy;
using ::memmove;
using ::strcpy;
using ::strncpy;
using ::strcat;
using ::strncat;
using ::memcmp;
using ::strcmp;
using ::strcoll;
using ::strncmp;
using ::strxfrm;
using ::strcspn;
using ::strspn;
using ::strtok;
using ::memset;
using ::strerror;
using ::strlen;
using ::memchr;
zhe
z这些函数得用法和作用是什么啊?
这样的英文我的头文件里也有啊,不用你说
不过还是要谢谢你!
String-Manipulation Routines
Routine Use .NET Framework equivalent
strcoll, wcscoll, _mbscoll, _strcoll_l, _wcscoll_l, _mbscoll_l, _stricoll, _wcsicoll, _mbsicoll, _stricoll_l, _wcsicoll_l, _mbsicoll_l, _strncoll, _wcsncoll, _mbsncoll, _strncoll_l, _wcsncoll_l, _mbsncoll_l, _strnicoll, _wcsnicoll, _mbsnicoll, _strnicoll_l, _wcsnicoll_l, _mbsnicoll_l
Compare two character strings using code page information (_mbsicoll and _mbsnicoll are case-insensitive)
System::String::Compare
_mbsdec, _mbsdec_l, _strdec, _wcsdec
Move string pointer back one character
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
_mbsinc, _mbsinc_l, _strinc, _wcsinc
Advance string pointer by one character
Not applicable.
_mbsnbcat, _mbsnbcat_l, _mbsnbcat_s, _mbsnbcat_s_l
Append, at most, first n bytes of one character string to another
Not applicable.
_mbsnbcmp, _mbsnbcmp_l
Compare first n bytes of two character strings
Not applicable.
_mbsnbcnt, _mbsnbcnt_l, _mbsnccnt, _mbsnccnt_l, _strncnt, _wcsncnt
Return number of character bytes within supplied character count
Not applicable.
_mbsnbcpy, _mbsnbcpy_l, _mbsnbcpy_s, _mbsnbcpy_s_l
Copy n bytes of string
Not applicable.
_mbsnbicmp, _mbsnbicmp_l
Compare n bytes of two character strings, ignoring case
Not applicable.
_mbsnbset, _mbsnbset_l
Set first n bytes of character string to specified character
Not applicable.
_mbsnbcnt, _mbsnbcnt_l, _mbsnccnt, _mbsnccnt_l, _strncnt, _wcsncnt
Return number of characters within supplied byte count
Not applicable.
_mbsnextc, _mbsnextc_l, _strnextc, _wcsnextc
Find next character in string
Not applicable.
_mbsninc, _mbsninc_l, _strninc, _wcsninc
Advance string pointer by n characters
Not applicable.
_mbsspnp, _mbsspnp_l, _strspnp, _wcsspnp
Return pointer to first character in given string that is not in another given string
Not applicable.
_scprintf, _scprintf_l, _scwprintf, _scwprintf_l
Return the number of characters in a formatted string
Not applicable.
_snscanf, _snscanf_l, _snwscanf, _snwscanf_l, _snscanf_s, _snscanf_s_l, _snwscanf_s, _snwscanf_s_l
Read formatted data of a specified length from the standard input stream.
Not applicable.
sscanf, _sscanf_l, swscanf, _swscanf_l, sscanf_s, _sscanf_s_l, swscanf_s, _swscanf_s_l
Read formatted data of a specified length from the standard input stream.
Not applicable.
sprintf, _sprintf_l, swprintf, _swprintf_l, __swprintf_l, sprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_l, _sprintf_p, _sprintf_p_l, _swprintf_p, _swprintf_p_l
Write formatted data to a string
System::String::Format
strcat, wcscat, _mbscat, strcat_s, wcscat_s, _mbscat_s
Append one string to another
System::String::Concat
strchr, wcschr, _mbschr, _mbschr_l
Find first occurrence of specified character in string
System::String::IndexOf
strcmp, wcscmp, _mbscmp
Compare two strings
System::String::CompareOrdinal
strcoll, wcscoll, _mbscoll, _strcoll_l, _wcscoll_l, _mbscoll_l, _stricoll, _wcsicoll, _mbsicoll, _stricoll_l, _wcsicoll_l, _mbsicoll_l, _strncoll, _wcsncoll, _mbsncoll, _strncoll_l, _wcsncoll_l, _mbsncoll_l, _strnicoll, _wcsnicoll, _mbsnicoll, _strnicoll_l, _wcsnicoll_l, _mbsnicoll_l
Compare two strings using current locale code page information (_stricoll, _wcsicoll, _strnicoll, and _wcsnicoll are case-insensitive)
System::String::Compare
strcpy, wcscpy, _mbscpy, strcpy_s, wcscpy_s, _mbscpy_s
Copy one string to another
System::String::Copy
strcspn, wcscspn, _mbscspn, _mbscspn_l
Find first occurrence of character from specified character set in string
System::String::Substring
_strdup, _wcsdup, _mbsdup, _strdup_dbg, _wcsdup_dbg
Duplicate string
System::String::Clone
strerror, _strerror, _wcserror, __wcserror, strerror_s, _strerror_s, _wcserror_s, __wcserror_s
Map error number to message string
System::Exception::Message
strftime, wcsftime, _strftime_l, _wcsftime_l
Format date-and-time string
System::Convert::ToString
_stricmp, _wcsicmp, _mbsicmp, _stricmp_l, _wcsicmp_l, _mbsicmp_l
Compare two strings without regard to case
System::String::Compare
strlen, strlen_l, wcslen, wcslen_l, _mbslen, _mbslen_l, _mbstrlen, _mbstrlen_l, strnlen, strnlen_l, wcsnlen, wcsnlen_l, _mbsnlen, _mbsnlen_l, _mbstrnlen, _mbstrnlen_l
Find length of string
System::String::Length
_strlwr, _wcslwr, _mbslwr, _strlwr_l, _wcslwr_l, _mbslwr_l, _strlwr_s, _strlwr_s_l, _mbslwr_s, _mbslwr_s_l, _wcslwr_s, _wcslwr_s_l
Convert string to lowercase
System::String::ToLower
strncat, _strncat_l, wcsncat, wcsncat_l, _mbsncat _mbsncat_l, strncat_s, _strncat_s_l, wcsncat_s, _wcsncat_s_l, _mbsncat_s, _mbsncat_s_l
Append characters of string
System::String::Concat
strncmp, wcsncmp, _mbsncmp, _mbsncmp_l
Compare characters of two strings
System::String::Compare
strncpy, _strncpy_l, wcsncpy, _wcsncpy_l, _mbsncpy, _mbsncpy_l, strncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_l
Copy characters of one string to another
System::String::Copy
_strnicmp, _wcsnicmp, _mbsnicmp, _strnicmp_l, _wcsnicmp_l, _mbsnicmp_l
Compare characters of two strings without regard to case
System::String::Compare
_strnset, _strnset_l, _wcsnset, _wcsnset_l, _mbsnset, _mbsnset_l
Set first n characters of string to specified character
System::String::Replace
strpbrk, wcspbrk, _mbspbrk, _mbspbrk_l
Find first occurrence of character from one string in another string
System::String::IndexOfAny
strrchr, wcsrchr, _mbsrchr, _mbsrchr_l
Find last occurrence of given character in string
System::String::LastIndexOf
_strrev, _wcsrev, _mbsrev, _mbsrev_l
Reverse string
Not applicable.
_strset, _strset_l, _wcsset, _wcsset_l, _mbsset, _mbsset_l
Set all characters of string to specified character
Not applicable.
strspn, wcsspn, _mbsspn, _mbsspn_l
Find first substring from one string in another string
System::String::Substring
strstr, wcsstr, _mbsstr, _mbsstr_l
Find first occurrence of specified string in another string
System::String::IndexOf
strtok, _strtok_l, wcstok, _wcstok_l, _mbstok, _mbstok_l, strtok_s, _strtok_s_l, wcstok_s, _wcstok_s_l, _mbstok_s, _mbstok_s_l
Find next token in string
Not applicable.
_strupr, _strupr_l, _mbsupr, _mbsupr_l, _wcsupr_l, _wcsupr, _strupr_s, _strupr_s_l, _mbsupr_s, _mbsupr_s_l, _wcsupr_s, _wcsupr_s_l
Convert string to uppercase
System::String::ToUpper
strxfrm, wcsxfrm, _strxfrm_l, _wcsxfrm_l
Transform string into collated form based on locale-specific information
Not applicable.
vsprintf, _vsprintf_l, vswprintf, _vswprintf_l, __vswprintf_l, vsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_l, _vsprintf_p, _vsprintf_p_l, _vswprintf_p, _vswprintf_p_l
Write formatted output using a pointer to a list of arguments
System::String::Format
vsnprintf, _vsnprintf, _vsnprintf_l, _vsnwprintf, _vsnwprintf_l, vsnprintf_s, _vsnprintf_s, _vsnprintf_s_l, _vsnwprintf_s, _vsnwprintf_s_l
Write formatted output using a pointer to a list of arguments
System::String::Format本回答被提问者采纳
C\C++关于string.h头文件和string类
学习C语言时,用字符串的函数例如stpcpy()、strcat()、strcmp()等,要包含头文件string.h
学习C++后,C++有字符串的标准类string,string类也有很多方法,用string类时要用到string.h头文件。
我现在很迷惑,这两个 string.h有什么区别。是怎么回事
我现在看vc的书上也有CString类,这个要包含什么,怎么用?
谢谢!
我还没见过#include<cstring>
turbo c 3.0里我要用c++的string标准类应包含什么头文件
为什么?
turbo c 3.0 里C++使用string.h 包含的是C语言的string.h
而不是 C++的string.h 为什么?
在C++环境包含C的string不是用cstring.h吗?
为什么tc 3.0不是这样呢 ?
VC++中有<string.h>文件,它就是C中的那个;
而<cstring>文件实际上只是在一个命名空间std中include了<string.h>,这是因为C++要减少名称污染;
所以两个都是可以用的,但C++鼓励用<cstring>。
<string>为字符串实现了一个类,而其实是依靠模板做的,这个可以先不考虑。使用类,可以将问题局部化,类似于把一个大问题分解成一个个小问题;而且类是具有类型安全的。
所以最好最好用C++的类。 参考技术A string.h头文件是用于C程序的。C++用来处理旧的C风格字符串,但一般用等价的头文件cstring。
string头文件中包含标准库类型string的定义,是在C++中处理字符串的一般方法。
在安全性上,string类比C风格的字符串要好的多,一般也比较易用。
补充:TC 3.0是一个很古老的C++编程环境(90年代初),由于C++的标准到1998年才公布,所以一些正确的程序在TC上是运行不了的,比如cstring这样的头文件。
最好的解决方案是抛弃TC,因为实际应用中已经没有人用这个十多年前的古董了。使用VC 6.0以后的版本、BCB较新的版本,或者开源的编程环境如Dev-C++(这个免费)。 参考技术B 你可以用标准的string,也可以用CString。如果没什么必要还是用string吧。
之所以有CString,那是历史原因。CString诞生的时候,C++标准还没出来。
--问题补充:为什么Turbo C++ 3.0却不可以用string呢?
--tc 3可以编c++的啊,怎么连string都用不了?
C++标准是98年出来的。tc3是98年以前出来的,所以你应该用新点的编译器。用VC2005,这个比较符合标准本回答被提问者和网友采纳 参考技术C 这两个一个是标准C库的,定义了一些字符串的处理函数.一个是标准C++库的,定义了标准C++的std::string类.
要用这个类要包含头文件<string>...如下;
#include <string>
using namespace std;//关于名字空间有兴趣自己查去,一般用标准库这句就行了
当然标准C库也是标准C++库的一部分,要用标准C库里的处理函数...如下:
#include <string.h>//所以你用这句包含的自是标C的头文件
...或者用如下C++风格的,它们是等价的,不过比较推荐:
#include <cstring>
using namespace std;
CString类是MFC的类,...不搞Windows MFC编程用不到 参考技术D 都是一样的,C++包含了C语言的所有功能,Cstring也就是C语言的类,在程序调用的什么两个都一样。
以上是关于cstring头文件里的函数怎么用的主要内容,如果未能解决你的问题,请参考以下文章