Final Fall 2005

Final Fall 2005 - CS 2213 Final 1. [10] Consider the...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 2213 Final 1. [10] Consider the following function: void funct(int u, int *v, int w) { printf(“%d %d %d %d\n”, u, v, w, *v); *v = u; v = &u; *v = w; printf(“%d %d %d %d\n”, *v, u); } What is printed from the following code (including what funct() prints) assuming that the address of x is 1000, that of y is 2000 and that of z is 3000; int x = 2, y = 3, z = 4; funct(x, &y, z); printf(“%d %d %d %d\n”, x, y, z, &y); 2. [20] Write a function, strmatch() , which will determine whether a given string matches the target string up through the length of the given string (but not including the null terminator). If there is a match then strmatch() will return 1 otherwise it will return 0. You may assume that the string pointers are non-NULL. The prototype is: int strmatch(char *s1, char *s2); which will see if s1 matches s2 for the length of s1. You must use pointers in this problem, no array manipulations. 3. [10] Use the strmatch() function above to write a function substr() which will return a pointer to the start of the first match of a given string s1 in the target string s2 and NULL if there is no match. char *substr(char *s1, char s2); 4. [20] Write a driver program to test the strmatch() function which will take the given string off the command line and read in one line at a time from the input file (second argument on the command line) and if there is a match print to the output file the line starting at the
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

Final Fall 2005 - CS 2213 Final 1. [10] Consider the...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online