Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int cmpfunc(const void* a, const void* b) {
  6.     return *(char*)a - *(char*)b;
  7. }
  8.  
  9. void AlphabetSort(char str[]) {
  10.     qsort(str, (size_t)strlen(str), (size_t) sizeof(char), cmpfunc);
  11. }
  12.  
  13. char** commonChars(char** A, int ASize, int* returnSize) {
  14.     int i;
  15.     //char* ch_arr1 = malloc(sizeof(char) * 10);
  16.     for (i = 0; i < ASize; i++) {
  17.         printf("%d: %s\n", i, A[i]);
  18.         AlphabetSort(A[i]);
  19.         printf("%s\n", A[i]);
  20.         //strcpy_s(ch_arr1, 5, A[i]);
  21.         //AlphabetSort(ch_arr1);
  22.         //printf("%s\n", ch_arr1);
  23.     }
  24. }
  25.  
  26.  
  27.  
  28. int main() {
  29.     char* words[] = {
  30.         "cool",
  31.         "lock",
  32.         "cook",
  33.     }; 
  34.     int returnedSize = 0;
  35.     char** rwords = NULL;
  36.     rwords = commonChars(words, 3, &returnedSize);
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement