C coding

sakthi.eeswari's Avatar
Go4Expert Member
Hi ,
Can any one help me.I need the C coding for sort n number of names using pointers and functions in alphabetical order.plz help me.

kingo's Avatar
Go4Expert Member

void bubble(char *items, int count);

void main()
	char s[255];
	printf("\nEnter a string : ");
	bubble(s, strlen(s));
	printf("\nThe sorted string is : %s", s);

void bubble(char *items, int count)
	int a, b;
	char t;

	for (a = 1; a < count; a++)
	for (b = count - 1; b >= a; b--)
	   if(items[b-1] > items[b])
	     t = items[b-1];
	     items[b-1] = items[b];
	     items[b] = t;

Last edited by shabbir; 26Sep2006 at 10:38.. Reason: Code formating.