C Program to Sort Elements in Lexicographical Order (Dictionary Order)

To understand this example, you should have the knowledge of the following C programming topics:


Sort strings in the dictionary order

Output

Enter 5 words: R programming
JavaScript
Java
C programming
C++ programming

In the lexicographical order:
C programming
C++ programming
Java
JavaScript
R programming

To solve this program, a two-dimensional string named str is created. The string can hold a maximum of 5 strings and each string can have a maximum of 50 characters (including the null character).

In the program, we have used two library functions:

These functions are used to compare strings and sort them in the correct order.