1
0

strexpected0 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. 2009-09-15 QSORT(3)
  2. int(*compar)(const void *, const void *));
  3. puts(argv[j]);
  4. pointers to char", but strcmp(3) arguments are "pointers
  5. to char", hence the following cast plus dereference */
  6. exit(EXIT_FAILURE);
  7. fprintf(stderr, "Usage: %s <string>...\n", argv[0]);
  8. /* The actual arguments to this function are "pointers to
  9. exit(EXIT_SUCCESS);
  10. for (j = 1; j < argc; j++)
  11. if (argc < 2) {
  12. int j;
  13. qsort(&argv[1], argc - 1, sizeof(argv[1]), cmpstringp);
  14. return strcmp(* (char * const *) p1, * (char * const *) p2);
  15. }
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. Another example is the following program, which sorts the strings given
  21. For one example of use, see the example under bsearch(3).
  22. Library routines suitable for use as the compar argument include alpha†SVr4, 4.3BSD, C89, C99.
  23. The qsort() function sorts an array with nmemb elements of size size.
  24. The base argument points to the start of the array.
  25. The comparison function must return an integer less than, equal to, or
  26. The contents of the array are sorted in ascending order according to a
  27. The qsort() function returns no value.
  28. This page is part of release 3.35 of the Linux man-pages project. A
  29. arguments that point to the objects being compared.
  30. be found at http://man7.org/linux/man-pages/.
  31. cmpstringp(const void *p1, const void *p2)
  32. compare as equal, their order in the sorted array is undefined.
  33. comparison function pointed to by compar, which is called with two
  34. description of the project, and information about reporting bugs, can
  35. greater than zero if the first argument is considered to be respec†in its command-line arguments:
  36. int
  37. main(int argc, char *argv[])
  38. qsort - sorts an array
  39. sort(1), alphasort(3), strcmp(3), versionsort(3)
  40. sort(3) and versionsort(3). To compare C strings, the comparison func†static int
  41. tion can call strcmp(3), as shown in the example below.
  42. tively less than, equal to, or greater than the second. If two members
  43. void qsort(void *base, size_t nmemb, size_t size,
  44. {
  45. {
  46. }
  47. }
  48. COLOPHON
  49. CONFORMING TO
  50. DESCRIPTION
  51. EXAMPLE
  52. NAME
  53. NOTES
  54. QSORT(3) Linux Programmer's Manual QSORT(3)
  55. RETURN VALUE
  56. SEE ALSO
  57. SYNOPSIS