私は明らかに何か間違ったことをしていますが、私の人生では何が悪いのかわかりません。
int main(int argc, char *argv[])
{
int done=0;
int end=0;
int didswap=0;
char *temp[2] = {0};
int i;
int x;
printf("This function Bubble sorts the Flintstones in alphabetical order!\n");
printf("The Flintstones names are:\nFred\nBarney\nWilma\nPebbles\nDino\n");
char *names[5] = {0};
names [0] = "Fred";
names [1] = "Barney";
names [2] = "Wilma";
names [3] = "Pebbles";
names [4] = "Dino";
while(end == 0)
{
for(i=0;i<4;i++)
{
if (strcmp(names[i],names[i+1])>0)
{
strcpy(temp[0],names[i]);
strcpy(temp[1],names[i+1]);
strcpy(names[i],temp[1]);
strcpy(names[i+1],temp[0]);
didswap = 1;
}
else
{
didswap = 0;
}
done = done+didswap;
}
if (done == 0)
end = 1;
else
done = 0;
}
printf("When alphabetized they are:\n");
for (i = 0; i < 5; i++)
{
printf("%s \n", names[i]);
}
system("PAUSE");
return EXIT_SUCCESS;
}