473,491 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

<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 4422
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2037
by: Arne Schirmacher | last post by:
I want to display a MySQL database field that can contain HTML markup. If I use <esql:get-string> then I get all of the database field, but all tags are escaped which is not what I want. If I use...
5
75012
by: Andrew Robinson | last post by:
Any easy answer what is wrong here? private List<string> BodyWords = new List<string>(); string word = "Andrew"; the following causes a compilation error:
6
46155
by: buzzweetman | last post by:
Many times I have a Dictionary<string, SomeTypeand need to get the list of keys out of it as a List<string>, to pass to a another method that expects a List<string>. I often do the following: ...
5
3525
by: Gary Wessle | last post by:
whats an efficient way to copy a string to a vector<string>? how about this? #include <iostream> #include <string> #include <vector> Using namespace std;
2
5851
by: Assimalyst | last post by:
Hi I have a Dictionary<string, List<string>>, which i have successfully filled. My problem is I need to create a filter expression using all possible permutations of its contents. i.e. the...
4
3930
by: parez | last post by:
Hi, I am trying to serialize List<List<string>. With the following code public List<List<string>DataRows { get; set; }
6
7328
by: Mr. K.V.B.L. | last post by:
I want to start a map with keys but an empty vector<string>. Not sure what the syntax is here. Something like: map<string, vector<string MapVector; MapVector.insert(make_pair("string1",...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.