K & R - Numerical alpha characters?

What does the numerical sorting of alpha characters mean as opposed to lexicographic ones, for example, in K & R 5-14 with the -n option

+3
source share
2 answers

In the second edition of K & R, section 5.11, the comparison function

int numcmp(char *s1, char *s2); /* defined on page 121 */

used for digital sorting (as opposed to use strcmpfor lexicographic sorting). numcmpcalls a function

double atof(char s[]); /* defined on page 71 */

which converts the string to a double-precision floating-point equivalent.

In the example, sorting with a command line argument -nis done using the values doublereturned by the function atof.

0
source

, , , . K & R numcmp, 5-14. char* double , . , 103 23, 103 23. , 103 23, 1 2.

+4

All Articles