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*/

	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;


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

		printf("\n..enter 1 to continue and 0 to exit\n");
       /* 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


			strcpy(temp,cu[j].name);		                                strcpy(cu[j].name,cu[k].name);

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


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.