20:499 learn-ap-southeast-1-prod-fleet02-xythos.s3-ap-southeast-1.am arse Code: CSCI1540 (2019-20, Term 1) Page 4 of 6 4. (20

20:499 learn-ap-southeast-1-prod-fleet02-xythos.s3-ap-southeast-1.am arse Code: CSCI1540 (2019-20, Term 1) Page 4 of 6 4. (20%) Write a program (file name: 04.cpp) with a function int keepsome (const char xil, const char yll, char z[l, int ni, int n2); that copies all characters from array x to z with the exception of all characters in y. Parameter nl is the size of arrays x and z. Parameter n2 is the size of array y. The function returns the num- ber of characters copied to array z. The following shows some sample function calls and the expected contents of z and return value. (In the examples below, the single-quotes for characters are omitted for clarity.) Contents of x Contents of y ni n2 Expected Return contents of z value | 1,1,0,0,e,C.S.C.I .I.C 9 3 1.0.v.S Dr,L,a,w,I,,G,0,0,d a,e,i,o,u 11 5 Dr,L,w,I,,G,d 8 a,b,c,d, e f .g.hi5 4 a,b,c,d,e 5 Note: • What you write in the main() function is unimportant. It can contain code to test the required function. We shall grade only the required function.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *