Difference between revisions of "CSC231 Final Exam Fall 2017"
Line 47: | Line 47: | ||
=Problem 2: C function= | =Problem 2: C function= | ||
<br /> | <br /> | ||
− | Write a C function called zap2() that will work similarly to the zap() function of Homework 9, but will replace '''all''' occurrences of the second string in the first string. | + | Write a C function called zap2() that will work similarly to the zap() function of Homework 9, but will replace '''all''' occurrences of the second string in the first string. |
− | For example, zap2( "Mississippi", "ss" ) will | + | zap2() will return 1 if one or more substitutions occur, and 0 otherwise. Note that zap2() does not return the number of substitutions, just 1 if one or more substitutions occurred. |
+ | |||
+ | For example, zap2( "Mississippi", "ss" ) will change the first string in "Mi--i--ppi", and will return 1. zap2( "Mississipi", "tt" ) will not change the first string and will return 0. | ||
Store your program in a file containing zap2() and any other function you need. Your program should not contain a main function, as it will be linked with a test program that will contain main(). | Store your program in a file containing zap2() and any other function you need. Your program should not contain a main function, as it will be linked with a test program that will contain main(). |