帮忙看下关于把字符串按照顺序输出的代码
#include"string.h"#include "stdio.h"
void main()
{
void sort(char *name[],int n);
char *name[]={"c","b","e","d","a"};
int n=5;
int i;
sort(name,n);
for(i=0;i<n;i++)
printf("%s",name);
}
void sort(char *name[],int n)
{
char *temp;
int i,j;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(strcmp(name,name)>0)
temp=name;name=name;name=temp;
}
}
} 为什么打印出来是
a deee
页:
[1]