strcmp( const char *cmp1, const char *cmp2 );
it will return zero if they are equal, non-zero (see detail in source link) means not equal.
2007-03-10 05:45:01
·
answer #1
·
answered by TBone 2
·
0⤊
0⤋
You can use the function strcmp. The function interface is int
strcmp(const char *s1, const char *s2), where s1 and s2 are the functions which needs to be compared. The function returned zero if the two strings are equal. A non zero value means the strings are not equal. But this value itself has some meaning. Its a big explanation and cant be given here.
2007-03-11 19:10:16
·
answer #2
·
answered by manoj Ransing 3
·
0⤊
0⤋
strcmp() is the best function i think but it has been declared depracated in Visual Studio .NET 2005.
The following safe function can be used instead. The parameter
max ensures that the function will safely return even if parameter strings are not null terminated.
int compare(char* a, char* b, int max)
{
int i=0;
while(a[i]&&max)
{
if(a[i]!=b[i]) return 0;
max--;
i++;
}
return 1;
}
2007-03-10 06:01:56
·
answer #3
·
answered by Ajib 1
·
0⤊
0⤋
To compare two strings, you need to use comparestring function.
2007-03-11 16:27:18
·
answer #4
·
answered by Pawan one 2
·
0⤊
0⤋
What does it advise to get the ASCII equivalent? Characters are stored(on maximum implementations) as ASCII (or utf-8, of which ASCII is a subset), so there isn't something to 'get', it somewhat is already there. you may evaluate characters immediately, in a for loop. make specific to objective for the null terminator('0' or purely 0) to be responsive to whilst the string is ended.
2016-10-18 01:11:09
·
answer #5
·
answered by Anonymous
·
0⤊
0⤋
using string function strcmp i.e
int strcmp(const char *str1,const char *str2)
wat i have studied is this rest i dont no.
2007-03-10 05:53:41
·
answer #6
·
answered by kanika 1
·
0⤊
0⤋
#include
#include
#include
main()
{
string str1;
string str2;
gets(str1);// accept first string
gets(str2);// accept second string
// compare both strings
if(strcmp(str1,str2) > 0)
printf(str1 + " is greater than " + str2);
elseif(strcmp(str1,str2) < 0)
printf(str2 + " is greater than " + str1);
else
printf(str1 + " is equal to " + str2);
getch();
return 0;
}
2007-03-10 08:50:20
·
answer #7
·
answered by saba 2
·
0⤊
0⤋