what are the differences of string and cstring header files and how does the pre defined function of strcmp which is called string comparison works???? i know it gives 0 if string 1 = string 2 gives +ive and -ive if str1 is greater or less but it calculates that which one is greater????someone help??
Builder_1
-6
Junior Poster in Training
Recommended Answers
Jump to PostThe two headers are completely different.
cstring
is inherited from C and provides functions for working with C-style strings (arrays of char terminated by'\0'
).string
was born in C++ and defines thestd::string
class along with its non-member functions.
strcmp
works like this:
Jump to PostThe strcmp() function compares the ASCII values of the characters one by one
It compares the numeric values of the characters. It's not safe to assume that the character set is ASCII. Granted, ASCII and Unicode (where ASCII is a subset) are pervasive, but but not universal.
All 7 Replies
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Moschops
683
Practically a Master Poster
Featured Poster
Builder_1
-6
Junior Poster in Training
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Builder_1
-6
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.