Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

<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 <string> is C++ standard library headers?

Report this thread to moderator Post Follow-up to this message
Old Post
Carmen Sei
04-03-08 12:37 AM


Re: <string.h> vs <string>
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.

Report this thread to moderator Post Follow-up to this message
Old Post
Ian Collins
04-03-08 12:37 AM


Re: <string.h> vs <string>
"Ian Collins" <ian-news@hotmail.com> wrote in message
news:65igpdF2g3gvtU1@mid.individual.net...
> Carmen Sei wrote: 
>
> No, it's an obsolete C++ header.

Are you sure? Have you looked at <cstring>?

Sharad



Report this thread to moderator Post Follow-up to this message
Old Post
Sharad
04-03-08 12:37 AM


Re: <string.h> vs <string>
Sharad wrote:
> "Ian Collins" <ian-news@hotmail.com> wrote in message
> news:65igpdF2g3gvtU1@mid.individual.net... 
>
> Are you sure? Have you looked at <cstring>?
>
Oops, I misread the OP.

--
Ian Collins.

Report this thread to moderator Post Follow-up to this message
Old Post
Ian Collins
04-03-08 12:37 AM


Re: <string.h> vs <string>
"Carmen Sei" <fatwallet951@yahoo.com> wrote in message
 news:js28v3to5i8qm6cfammju25gb0na4mh0is@
4ax.com...
> it seem to me that when doing include -
>
> #include <string.h> - is CRT
> #inlcude <string> - is C++ standard library

The intention of <string.h> is for the C style string category of functions
like strcpy, strlen etc. <string> is meant for the std::string class in the
C++ Standard library. At least with Comeau just including <string> takes
care of <string.h> also, but I am not sure if it's yet a standard behavior.

Sharad



Report this thread to moderator Post Follow-up to this message
Old Post
Sharad
04-03-08 12:37 AM


Re: <string.h> vs <string>
Ian Collins wrote:
> Carmen Sei wrote: 
>
> 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.

Report this thread to moderator Post Follow-up to this message
Old Post
Ron Natalie
04-03-08 12:37 AM


Re: <string.h> vs <string>
Sharad wrote:
> "Carmen Sei" <fatwallet951@yahoo.com> wrote in message
>  news:js28v3to5i8qm6cfammju25gb0na4mh0is@
4ax.com... 
>
> The intention of <string.h> is for the C style string category of function
s
> like strcpy, strlen etc. <string> is meant for the std::string class in th
e
> C++ Standard library. At least with Comeau just including <string> takes
> care of <string.h> also, but I am not sure if it's yet a standard behavior
.
>
> Sharad
>
It is allowed for it to do this.
It is not REQUIRED for it to do so.

If you're going to need the C string functions, you need to include
string.h or cstring.

>

Report this thread to moderator Post Follow-up to this message
Old Post
Ron Natalie
04-03-08 12:37 AM


Re: <string.h> vs <string>
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 <string> is 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
tazmaster@rocketmail.com



Report this thread to moderator Post Follow-up to this message
Old Post
Jim Langston
04-03-08 11:17 AM


Re: <string.h> vs <string>
On 2008-04-03 01:50:28 -0400, "Jim Langston" <tazmaster@rocketmail.com> said
:

> Carmen Sei wrote: 
>
> 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 fro
nt
> 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)


Report this thread to moderator Post Follow-up to this message
Old Post
Pete Becker
04-03-08 11:17 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

C++ archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:52 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.