Question
21. The statement strcmp(s1, s2) returns 0 if A. s1 has the same length as s2 B. s1 is the same as s2 pg. 7
21. The statement strcmp(s1, s2) returns 0 if A. s1 has the same length as s2 B. s1 is the same as s2 pg. 7 C. s1 is NULL or s2 is NULL D. None of the above
22. Write a function that compares two strings and s1 and s2 and returns the index of the first character that is not equal between the two strings. For example if s1 =day1 and s2=key2 then the function needs to return 2. A. Use array indices to solve the problem. B. Use only pointers to solve the problems 23. Write a function that two parameters source and destination and copies the string source to a string destination. The function should allocate memory for the destination string. If the operation is successful then the function returns 0, if the function fails it should return 1. Function prototype int copyString(char **destination, char *source); 24. Write a function that takes copies the string source to a string destination. The function should allocate memory for the destination string. If the operation is successful then the function returns 0, if the function fails it should return 1. Function prototype int copyString(char **destination, char *source); 25. Write a function myStrConcatenate(char *s1, char *s2, char **s3) that copies string concatenate strings s1 and s2 into string s3. For example if s1=nice and s2=day! then s3 will be nice day!. The function needs to allocate the exact memory for s3. 26. Write a function that allocates memory for a two-dimensional array arr2D of integers. #define DIM_1 5 #define DIM_2 10 int **arr2D = NULL // Add code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started