469,270 Members | 1,790 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

<string.h> vs <string>

it seem to me that when doing include -

#include <string.h- is CRT
#inlcude <string- is C++ standard library

Is that true those header with .h extension is CRT and those without
extension <stringis C++ standard library headers?
Apr 2 '08 #1
8 4143
Carmen Sei wrote:
it seem to me that when doing include -

#include <string.h- is CRT
No, it's an obsolete C++ header.

There isn't a "CRT", there's the C and C++ standard libraries. The
latter includes the former.

--
Ian Collins.
Apr 2 '08 #2

"Ian Collins" <ia******@hotmail.comwrote in message
news:65*************@mid.individual.net...
Carmen Sei wrote:
>it seem to me that when doing include -

#include <string.h- is CRT

No, it's an obsolete C++ header.
Are you sure? Have you looked at <cstring>?

Sharad
Apr 2 '08 #3
Sharad wrote:
"Ian Collins" <ia******@hotmail.comwrote in message
news:65*************@mid.individual.net...
>Carmen Sei wrote:
>>it seem to me that when doing include -

#include <string.h- is CRT
No, it's an obsolete C++ header.

Are you sure? Have you looked at <cstring>?
Oops, I misread the OP.

--
Ian Collins.
Apr 2 '08 #4
Ian Collins wrote:
Carmen Sei wrote:
>it seem to me that when doing include -

#include <string.h- is CRT

No, it's an obsolete C++ header.

There isn't a "CRT", there's the C and C++ standard libraries. The
latter includes the former.
The latter includes an obsolete version of the former.
Apr 2 '08 #5
Carmen Sei wrote:
it seem to me that when doing include -

#include <string.h- is CRT
#inlcude <string- is C++ standard library

Is that true those header with .h extension is CRT and those without
extension <stringis C++ standard library headers?
Not always. An OS/Compiler specific header may have a .h or not, usually
they do though.

Most headers without an extention are part of the STL.

Some headers with an .h extention are from the C routines.

However, the standard C headers can be included by adding a 'c' to the front
and removing the exteion. I.E.
#include <string.h>
becomes
#include <cstring>

So how would you catagorize cstring?

--
Jim Langston
ta*******@rocketmail.com
Apr 3 '08 #6
On 2008-04-03 01:50:28 -0400, "Jim Langston" <ta*******@rocketmail.comsaid:
Carmen Sei wrote:
>it seem to me that when doing include -

#include <string.h- is CRT
#inlcude <string- is C++ standard library

Is that true those header with .h extension is CRT and those without
extension <stringis C++ standard library headers?

Not always. An OS/Compiler specific header may have a .h or not, usually
they do though.

Most headers without an extention are part of the STL.

Some headers with an .h extention are from the C routines.

However, the standard C headers can be included by adding a 'c' to the front
and removing the exteion. I.E.
#include <string.h>
becomes
#include <cstring>

So how would you catagorize cstring?
Let me restate that. Among the headers defined in the C++ standard:

Headers without an extension describe names in the C++ standard library.
Headers with a .h extension describe names in the C standard library,
and put those names in the global namespace.
Headers with names that are the same as the C headers but with a 'c' in
front and no extension put names from the C standard library into
namespace std.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Apr 3 '08 #7
Is that true those header with .h extension is CRT and those without
extension <stringis C++ standard library headers?

Not always. An OS/Compiler specific header may have a .h or not, usually
they do though.
But also note (and just to clarify the above correct statement) that
<string.h(as with several other header files) is an unsupported (or
non standard) header and should NOT be used in modern code. It is
usually put there so that old legacy code (and examples in old books)
will not break, but it is not an official part of the C or C++
libraries (It is there for historical compatibility ONLY).

All C++ header files do NOT have a .h
i.e. <strings>

All (I think) C header files have a C++ version that puts the
declarations in the std namespace. The C++ version has the same base
name as the C version but drops the '.h' and prefix a 'c.
i.e. <ctype.h is <cctype>
etc.
Apr 3 '08 #8
On 2008-04-03 12:00:13 -0400, Martin York <Ma***************@gmail.comsaid:
>
>>Is that true those header with .h extension is CRT and those without
extension <stringis C++ standard library headers?

Not always. An OS/Compiler specific header may have a .h or not, usually
they do though.

But also note (and just to clarify the above correct statement) that
<string.h(as with several other header files) is an unsupported (or
non standard) header and should NOT be used in modern code.
It is both standard C and standard C++. It is deprecated in the C++
standard, which means that in some future standard it might not be
supported. But that's wishful thinking. In any event, it is part of
the current standard and part of C++0x, and its meaning is well defined.
It is
usually put there so that old legacy code (and examples in old books)
will not break, but it is not an official part of the C or C++
libraries (It is there for historical compatibility ONLY).

All C++ header files do NOT have a .h
i.e. <strings>
There is no standard header with that name.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Apr 3 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Gary Wessle | last post: by
4 posts views Thread by parez | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.