Link to home
Start Free TrialLog in
Avatar of Kisses93834
Kisses93834

asked on

Looking for lexicographical_compare example

Please post lexicographical_compare example
Avatar of cryptosid
cryptosid

u didn't specify what type of lexicopgraphical compare... what do u want to compare what is the source etc...

anyways u have direct functions under string.h
strcmp() (case sensitive)
strcmpi() (case insensitive)

for comparision

u just need to specify

strcmp(s1,s2)
will return 0 if s1=s2
will return >0 if s1 > s2
will return <0 if s1 < s2

strcmpi() behaves in the same fashion

if u wanna create ur own function to simply check whether there is a match or not its like this

the function is

int StringCompare(char *s1,char *s2)
{
    int i=0,ret_val = 0;

    while((s1[i]==s2[i])&&s1[i]!=NULL&&s2[i]!=NULL)
          i++;
    if(s1[i]==NULL&&s2[i]==NULL)
    {
        //MATCH FOUND
        ret_val = 1;
    }
    return ret_val;
}

the above function returns 1 if a match is found and 0 if a match is not found....
Avatar of Kisses93834

ASKER

I'm reffering to the lexicographical_compare function that is part of the std standard template library.

I need an example using that function.
ASKER CERTIFIED SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial