- The function returns 1 when the strings are equal and 0 when they are not equal
- The function returns 1 when they are not equal
- The function returns 1 when the first string is greater than the second and returns -1 when the first one is less than the second one
Information about resetting and configuring Mobile phones (Java, Android, Symbian etc), educational articles especially for programming in C, C++ and Java and more about Computers and operating systems
Showing posts with label string compare. Show all posts
Showing posts with label string compare. Show all posts
String Comparison in C and C++ Languages and Working of strcmp function
In both C and C++ programming languages, an inbuilt function strcmp() is used to compare two strings. This function is defined in string.h header file. So, to use this function, you have to include the header file string.h in the program. Most of the people ( i mean beginners) have a wrong idea about the working of the this function. I also had made some false assumptions. This function takes two strings as arguments. And it compares the two strings using the ASCII equivalent of each character. Some of the false ideas about this function are:
Labels:
$ccpp
,
c program
,
C++
,
codes
,
comparison
,
function
,
inbuilt
,
language
,
programming
,
return value
,
strcpy
,
string
,
string compare
,
string sort
Subscribe to:
Posts
(
Atom
)