RSS Forums RSS
Please support our C advertiser: Programming Forums

sorting an array of string

Join Date: May 2004
Posts: 251
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Rep Power: 6
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: sorting an array of string

  #9  
Jun 11th, 2004
hey,here a simple way to see which of 2 strings is greater

int str_alp(char *s1,char *s2)
{
    if(strcmp(s1,s2)==0)return(0);   //if they are equal

        for(int i=0;s1[i]!=0;i++)
        {
              if(s1[i] > s2[i])return(1);
              else if(s1[i] < s2[i])return(2);
        }

    return (2);  //hey if they are not equal and s1 not greater than s2 then s2 is greater
}

See if you can use it
See what you can, remember what you need

Fourzon | Earn via Coding
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:15 pm.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC