strverscmp(3) Library Functions Manual strverscmp(3) strverscmp - Standard C library (libc, -lc) #define _GNU_SOURCE /* . feature_test_macros(7) */ #include int strverscmp(const char *s1, const char *s2); For a dataset like jan1, jan2, ..., jan9, jan10, ... sorting it lexicographically yields jan1, jan10, ..., jan2, ..., jan9. The task of strverscmp() is to compare two strings yielding the former order, while strcmp(3) finds only the lexicographic order. This function does not use the locale category LC_COLLATE, so is meant mostly for situations where the strings are expected to be in ASCII. This is different from the ordering produced by sort(1) -V. . , 0. , , . , ( , ) . , , strcmp(3) ( ). . , , ( , ). : 000, 00, 01, 010, 09, 0, 1, 9, 10. strverscmp() , , , , s1 , , s2. attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |strverscmp() | | MT-Safe | +----------------------------+----------------------------------------------------------+--------------------------+ GNU. strverscmp(). strverscmp() , . : $ ./a.out jan1 jan10 jan1 < jan10 #define _GNU_SOURCE #include #include #include int main(int argc, char *argv[]) { int res; if (argc != 3) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(EXIT_FAILURE); } res = strverscmp(argv[1], argv[2]); printf("%s %s %s\n", argv[1], (res < 0) ? "<" : (res == 0) ? "==" : ">", argv[2]); exit(EXIT_SUCCESS); } rename(1), strcasecmp(3), strcmp(3), strcoll(3) () Alexander Golubev , Azamat Hackimov , Hotellook, Nikita , Spiros Georgaras , Vladislav , Yuri Kozlov , Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux man-pages 6.12 16 2024 . strverscmp(3)