Accepted
/in/foo.c: In function 'main': /in/foo.c:12:9: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[10]' [-Wformat=] scanf("%s",&str); ^
代码
#include <stdio.h>
#include <string.h>
#define N 10
char str[N];
int main()
{
void sort(char []);
int i;
scanf("%s",&str);
sort(str);
//printf("string sorted:\n");
for(i=0;i<N;i++)
printf("%c",str[i]);
//printf("\n");
return 0;
}
void sort(char str[]){
int i,j;
char t;
for(j=1;j<N;j++)
for(i=0;(i<N-j)&&(str[i]!='\0');i++)
if(str[i]>str[i+1])
{t=str[i];
str[i]=str[i+1];
str[i+1]=t;
}
}