sorting an array of string

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

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

Re: sorting an array of string

 
0
  #11
Jun 11th, 2004
Just wanted to show how it works inside. It would sure help in understanding what goes on.

btw,what the use if all use something without knowing how it works
See what you can, remember what you need

Fourzon | Earn via Coding
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 15
Reputation: dooda man is an unknown quantity at this point 
Solved Threads: 0
dooda man dooda man is offline Offline
Newbie Poster

Re: sorting an array of string

 
-1
  #12
Jun 11th, 2004
hi miss matika. strncmp() is the easiet way for comparing strings and it helps in arranging.

for example if you want to arrange accoring to the first letter

strncmp(st1,st2,1) // 1 is the number of letters you are going arrange according to it.

1- the function returns 0 if the letters are the same
2- the function returns -1 if the first letter of st1 smaller than st2
3- the function returns 1 if the first letter of st2 smaller than st1

The question is : Is there is a function which switch the places of two strings with each other.

you can also use this function... balas(); " It is very usefull trust me "
but u must include "radi.h"
thnx
bye :cheesy:
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 256
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: sorting an array of string

 
0
  #13
Jun 12th, 2004
"radi.h" where can one find it eh?
See what you can, remember what you need

Fourzon | Earn via Coding
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 19
Reputation: matika is an unknown quantity at this point 
Solved Threads: 0
matika matika is offline Offline
Newbie Poster

Re: sorting an array of string

 
0
  #14
Jun 13th, 2004
Originally Posted by FireNet
"radi.h" where can one find it eh?
it's one of my colleages he likes to make jokes a lot
sorry
there is nothing called radi(); or a header file called "radi.h"
sorry guys agaian :o
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 34
Reputation: Fili is an unknown quantity at this point 
Solved Threads: 0
Fili's Avatar
Fili Fili is offline Offline
Light Poster

Re: sorting an array of string

 
0
  #15
Jun 17th, 2004
The answer is quite simple:
Just use "<"or">" operators in an "if" instruction like in a normal sorting method for numbers. Be careful though:
if you have:
s1[]="abcdef",s2[]="afsdg"; and you write
if (s1>s2) printf("1");
else printf("2"); it will write 2 as in s2 larger than s1 so s1 has to be first: abcdef, afsdg

Hope it helps! :cheesy:
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 34588 | Replies: 14
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC