April 2000
CA208 : 'C' PROGRAMMING

QUESTION 2

Total Marks: 15 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 2

(a)Write a function,called Copy the signature of which is given below,which will copy at most n characters from the string src into the string dst You may assume that dst is a character string with at least n+1 elements.
void Copy(const char* src, char* dst, int n); [5 marks ]

(b)Write a function,called IsMember the signature of which is given below which will return a pointer to the first instance of the character c in the string s If there is no occurrence of the character in the string,then the function should return NULL
char* IsMember(char* s, char c); [5 marks ]

(c)Write a function,called RemoveMember the signature of which is given below,which will take a string s and return a reference to the string with all occurrences of the character c removed from the string.For example,calling the function on the string abcabcabc with the character a to be removed wouldresult in the string bcbcbc.
void RemoveMember(char* s, char c); [5 marks ]