Programming in C autumn 2007
Exercise 6
To the exam you may take one A4 paper, where you have make your own notes.
You can use both sides of the paper.
Oct. 12 2007
struct employee { long id; char name[50]; double salary; };Write the following functions:
#define MAX 100 char* storage[MAX];input() reads the file fname and stores storage lines from this file in the array. Do not make any assumptions about the length of input lines (use a function getline() from Example 10-3). The function input() should then remove all lines that are empty (contain only the end-of-line character, possibly preceded by whitespace characters.) from this array, and report the number of lines that have been removed. Then write the main function which calls input(), and then outputs the contents of the array storage to the standard output stream.
void compareGen(const void *block1, const void *block2, size_t elemSize, size_t block1Size, size_t block2Size, int (*compareIt) (const void*, const void*));which performs a lexicographical comparison of the two blocks. Test your program using blocks of doubles and blocks of pointers to doubles.