Programming in C, Autumn 2007


Exercise 5

Oct. 5 2007

  1. Write a function that searches a given character. The function has as parameters a string and a character. The function returns a pointer to the first occurence of the searched character in the string. If the character is not found NULL is returned. Write also a main program from where the function is called.

  2. Write a functionvoid fill (char *p, int n, char pat),   to initialize n bytes of memory with the value pat, starting at address p.

  1. Write a program that takes a command line argument representing a number in Roman notation (for example, MXLIV) and outputs this number in standard notation. Consider only values less than 1000.

  2. Write a program find that takes as command line arguments a file name and a string (find file1 Java). Program prints all those lines that have the given string.

  3. Write an implementation of a queue. You can assume that the elements of the queue are for example doubles. Add into the code some asserts. Try also debugging using conditional compilation.

.