[ create a new paste ] login | about

Link: http://codepad.org/7BwJOikP    [ raw code | output | fork ]

C, pasted on Mar 21:
#define CLASS_SIZE 10
#include <stdio.h>

void bubbleSortAWriteToB(const char a[], char *b[]);

int main(void){
    char *s_letters[CLASS_SIZE];
    char letters[CLASS_SIZE] = {'a','r','p','b','r','c','x','e','w','j'};
    bubbleSortAWriteToB(letters,s_letters);
        return 0;
}

void bubbleSortAWriteToB(const char a[], char *b[]){
    char temp;
    int i,j;
    for(i=0;i<CLASS_SIZE-1;i++){
        for(j=1;j<CLASS_SIZE;j++){
            if((int)a[j-1]>(int)a[j]){
                temp = a[j];
                *b[j] = a[j-1];
                *b[j-1] = temp;

            }

    }

  }
}


Output:
1
Segmentation fault


Create a new paste based on this one


Comments: