> Hi, > > In tutorial 2, page 4 and 5 it shows how to do a string comparison. > I can see how the lexicography works. > My question is: > "Will this also work if the characters are numeric?". > In assignment #1, we have to sort records according to the student > number. Can the student numbers be compared as numeric character strings > using this method with 'strcmp'? Yes. Numeric characters have their ASCII code following the same numerical order ('0' has code 48, '1' has code 49,...,'9' has code 57). When comparing characters the ASCII code is used. (as an aside - 'A' has code 65 but 'a' has code '97' see ASCII table at page 579 of the book) > > If not, then I assume we have to convert the numeric character string to > an integer somehow, and then sort it according to the integer values. > If this is necessary, what is the command to convert the numeric > characters (student number) to an integer value? > // Convert the number string into a long int. n = atol(nstr); You probably need to include: #include which is the C standard library. Lucia