473,573 Members | 4,459 Online
Bytes | Software Development & Data Engineering Community
+ 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 4431
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******@hotma il.comwrote in message
news:65******** *****@mid.indiv idual.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******@hotma il.comwrote in message
news:65******** *****@mid.indiv idual.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*******@rocke tmail.com
Apr 3 '08 #6
On 2008-04-03 01:50:28 -0400, "Jim Langston" <ta*******@rock etmail.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.comsa id:
>
>>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
2051
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 <esql:get-xml> the tags are not escaped, but only the first part of the database field is displayed. The content of the database field is: ...
5
75109
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
46168
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: <BEGIN CODE> List<stringkeyNameList = new List<string>(); foreach (string keyName in this.myDictionary.Keys)
5
3540
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
5870
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 dictionary essentially creates the following array: Key Value
4
3942
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
7350
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", new vector<string>)); MapVector.insert(make_pair("string2", new vector<string>)); MapVector.insert(make_pair("string3", new vector<string>));
0
7661
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7978
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7730
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8028
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5550
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5252
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3692
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
987
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.