- what is string, string.h, cstring ??
- what is the difference between all these header file ??
- strlen() returns the length of string including null character or without null character ??
Doubts in header file
In C++ you should include cstring
as the header while in c you should include string.h
as the header.
In C++
#include <cstring>
In C
#include <string.h>
strlen() returns the number of data characters starting at the address passed to it. This does not include the null “character” which indicates string termination.
what is the difference string, cstring ??
string is a data type in c++
cstring is header file
string is also a header file
i am asking for the difference between string header file and cstring header file
-
<string.h>
contains old functions likestrcpy
,strlen
for C style null-terminated strings. -
<string>
primarily contains thestd::string
,std::wstring
and other classes.
It should also be noted that using string.h
is deprecated within C++. If you need the functionality contained within, you should use the header cstring
.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.