Search:

Type: Posts; User: Adak

Search: Search took 0.10 seconds.

  1. Replies
    34
    Views
    6,328

    Enjoy! :) Works fine. #include ...

    Enjoy! :) Works fine.



    #include <stdio.h>
    #include <string.h>

    int main() {
    int i, j, temp_num;
    int index[6];
  2. Replies
    34
    Views
    6,328

    The problem that I see is that your *b[] has...

    The problem that I see is that your *b[] has "ragged" amounts of char space, for each word.

    So b[0] has 5 chars (4 + end of string)
    but b[2] only has 2 chars in it.

    So when you start sorting,...
  3. Replies
    34
    Views
    6,328

    Try it with the new sort code. (I changed it in...

    Try it with the new sort code. (I changed it in the earlier post). Keep in mind that capital letters will always sort out lower than any lower case letters. That can throw you if you're used to case...
  4. Replies
    34
    Views
    6,328

    Selection sort is bubble sort with a slight...

    Selection sort is bubble sort with a slight optimization. It doesn't compare adjacent values except the first time it enters the inner for loop. It is in the same "family" of sorters as bubble sort....
  5. Replies
    34
    Views
    6,328

    Your code is for bubble sort, and this is...

    Your code is for bubble sort, and this is selection sort. Bubble sort compares only adjacent values, selection sort compares i and j indexed items, instead of i and i + 1. Bubble code might work...
  6. Replies
    34
    Views
    6,328

    You can use any sorting algorithm in conjunction...

    You can use any sorting algorithm in conjunction with strcmp.

    This is selection sort (very close to bubble sort)



    char temp[MAX]; //MAX = largest element of data in array
  7. Replies
    34
    Views
    6,328

    The strings have to be differentiated before you...

    The strings have to be differentiated before you can use strcmp(). It has to be able to find the strings before it can make any comparison.

    You have several buffers (char arrays). Can't you put a...
  8. Replies
    34
    Views
    6,328

    One way would be to copy each token string into a...

    One way would be to copy each token string into a 2D char array, one token string per row. Then sort the rows. You could do this using your buffers 2 - 5. Is that what you intended?

    A rather more...
  9. Replies
    34
    Views
    6,328

    I don't see any logic for sorting, but yes,...

    I don't see any logic for sorting, but yes, strcmp(string1, string2) is what you want. the return from strcmp() will be 0 if the strings are equal, or the open end of the <, sign, will point toward...
Results 1 to 9 of 9