Sort alphabetic into lower n in ascending order

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • changwl8888
    New Member
    • Mar 2010
    • 11

    Sort alphabetic into lower n in ascending order

    Sort line
    -----------------
    Enter a string (1-40 characters): CBA123fde[]aa
    Output: aaabcdef


    Above is the output i need..but i have done some code...and i dun have idea how to make it...could anyone help show me some easy example...

    below is my code...i dont think is correct..please correct me

    #include <stdio.h>
    #include <stdlib.h>

    #define LSIZE 50

    int main(void)
    {
    int i;
    char value;
    char textInput[50];
    int len;

    printf("Sort Line\n");
    printf("--------------------------------\n");
    printf("Enter a string:");


    scanf("%s",text Input);

    len=strlen(text Input);

    for (i=0; i <len; i++) {
    value = textInput[i];

    if (isalpha(value) ){
    textInput[i]=value;
    }
    else if(isdigit(valu e))
    {
    textInput-textInput[i];
    }else
    {
    textInput-textInput[i];
    }







    }
    printf("%s\n", textInput);


    }



    /* loop back until EOF */


    Help!!! Urgent
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    When you do textInput-textInput[i]; do you mean to put in
    textInput[i] = ' '
    or something like that?
    You might want to use a 2nd array to store your output.

    Comment

    Working...