Structures and Pointers – Strings – Problem #7
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Write a function void dict_first(char s[], int n, char * first), which given an array s of n (< 10) strings (each of length < 20), finds the first string in the array if the strings were arranged according to dictionary order. In the above function, use the strcmp function in the strings.h library to compare dictionary order between two strings. Write a main function which reads an integer n. Then reads n strings consisting of lower case alphabets only, calls the above function, and prints the first string according to dictionary order. Example, if n = 4, and the input strings are “hello”, “world”, “happy”, “diwali”, output string should be “diwali”.