CS13002 Programming and Data Structures

(Autumn semester)    Section A

Assignment Set - 7

Please write your Roll Number, Name and Assignment Number at the header of each program.


Assignment 6.a:        Filename: a7a.c

You have to write a program that performs the following tasks:

  1. It reads the name of a file into a string: char *fname;

  2. It reads the file to extract and print the following information:

        (a) The number of characters in the file
        (b) The number of alpha-numeric words in the file including duplicates
        (c) The number of lines in the file
     

  3. It also creates a sorted array of distinct alpha-numeric words in the file and prints them in lexicographic order

Alpha-numeric words contain only alphabets (that is, [A-Z], [a-z]) and numbers (that is, [0-9]). All other characters (including blanks, commas, hyphens, etc) do not belong to alpha-numeric words, but may be present in the file. While counting characters, you must count these characters also.

You are encouraged to use the standard string functions including:

To use these functions, you must include the header file, string.h.
You may also find the functions sscanf() and sprintf() useful for this assignment.


Course home