Fondamenti di Informatica

Fondamenti di Informatica

Prof. Evelina Lamma

29 July 2014

Exercise (20 points) (1 hour and 45 min)

A binary file, parole1.bin , contains some Italian words. The file is unsorted, and each word can be repeated. The words contain at most 20 characters, including the string terminator.
Create a C program, organized in at least three functions, that should perform the following tasks:

For students that take the full A+B exam (Further 20 points, on a total of 60 for the full A+B exam; time +45 min; tot 2.30 h):

In the parole1.bin  file there are at least 10 distinct words. Insert the first 10 distinct words of this file in an array V of size 10. Show the content of the array on the screen.
Sort the array V by using the function qsort, then print on a text file, named outputAB.txt, all the words in the array V. This task should be performed in a function called functionC that has, as parameters, the array V and the file pointer to file parole1.bin (plus other parameters, if necessary), and returns void.
The file outputAB.txt should be submitted together with the source code.
Note:   Submit the source files, the executable file, and the output file that have been generated by your program. In case the application consists of more files, all user libraries should be submitted as well.



File translated from TEX by TTH, version 4.03.
On 24 Jul 2014, 17:15.