even after passing all name to bubble sort i get result of unsorted nams..so please help me in this issue

/* enter customer detail in structure and put its name in asscending order*/
#include<stdio.h>
#include<string.h>


	int main(){

			
		int i=0;
		int j,k,l,m;
   		int choice=1;
                               char temp[10];
		char words[20];

	
		struct customer{

				char name[20];
				int account;
				int current;
				int debt;
				
		}cu[20];

		

	       	
	printf("\n ******enter details******* \n");
               	 while (choice==1){
				
		printf("\n enter customer detials\n");
			
		printf("\ncustomer name		:");
		scanf("%s",&cu[i].name);
		printf("\n account no		:");
		scanf(" %d",&cu[i].account);
		printf("\n debt			:");
		scanf("%d",&cu[i].debt);

	                        i++;
		printf("\n..enter 1 to continue and 0 to exit\n");
		scanf("%d",&choice);
	}
			
       /* putting all customer name in assceding order*/                

                        printf("\n all customer name in asceding order\n"); 	for(j=0;j<i-1;j++){//bubble sort

		for(k=j+1;k<i;k++){

						
	                      if(strcmp(cu[j].name,cu[k].name)>0){
			strcpy(temp,cu[j].name);		                                strcpy(cu[j].name,cu[k].name);
			 strcpy(cu[k].name,temp);
			 }
		 }
							
	}

	printf("\n list of customer in ascending order\n");
			
		for(l=0;l<i;l++){					printf("%s",words[l]);
		printf("\n");
	              }									    
                                       					



}

Where does words[] come into play? I see you declare it at the beginning and you try to display it at the end but it's no where in the middle...

Also, why is name 20 chars and temp 10 chars? What happens if you try to copy a long name into temp?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.