32static int arr_name_sorter(
const void* p1,
const void* p2)
34 const my_type *the_type1 = p1;
35 const my_type *the_type2 = p2;
37 return strcmp(the_type1->arr_name, the_type2->arr_name);
45void fms_sort_this(
char **arr,
int* n,
int*
id)
51 the_type = (my_type*)calloc(*n,
sizeof(my_type));
53 the_type[i].id =
id[i];
54 strcpy(the_type[i].arr_name, arr[i]);
57 qsort(the_type, *n,
sizeof(my_type), arr_name_sorter);
61 id[i] = the_type[i].id;
62 strcpy(arr[i], the_type[i].arr_name);
72char* fms_find_my_string_binding(
char** arr,
int *n,
char *find_me,
int *np)
86 m = ceil((L + R) / 2);
90 is_found = strcmp(find_me,(arr[m]));
94 p = malloc(
sizeof(
int) * *np);
101 while (is_found == 0) {
104 is_found = strcmp(find_me,(arr[mm]));
105 if (is_found == 0 ) {
107 p = realloc(p,
sizeof(
int) * *np);
111 }
else {is_found = -999;}
117 while (is_found == 0) {
120 is_found = strcmp(find_me,(arr[mm]));
121 if (is_found == 0 ) {
123 p = realloc(p,
sizeof(
int) * *np);
127 }
else {is_found = -999;}
131 }
else if (is_found > 0) {
156 for(i=0; i<*np; i++){
157 if (i == *np-1) {sprintf( &
string[ strlen(
string) ],
"%d ", p[i] );}
158 else {sprintf( &
string[ strlen(
string) ],
"%d ,", p[i] );}
161 string_p = (
char*) malloc((strlen(
string)+1)*
sizeof(char));
162 strcpy(string_p,
string);
172int fms_find_unique(
char** arr,
int *n)
176 int * ids = calloc(*n,
sizeof(
int));
178 fms_sort_this(arr, n, ids);
182 if (strcmp(arr[i], arr[i-1]) != 0){ nfind = nfind + 1;}
193char * cstring2cpointer (
char * cs)