Action()
{
char str[]="yzhgseadcf";
char newstr[10];
int len=strlen(str);
int i=0, j=0;
char temp=‘\0‘;//临时变量
for(i=0; i<len; i++){
for(j=0; j<len-1-i; j++){ /*冒泡排序法*/
if(str[j] > str[j+1]){
temp = str[j];
str[j] = str[j + 1];
str[j + 1] = temp;
}
}
}
strncpy(newstr, str, 5);//截取字符串长度
lr_output_message("转换后的字符串%s=====",newstr);
return 0;
}
原文:http://www.cnblogs.com/flowersummer/p/4576614.html