Write the following function that compares at most n bytes


1. Write the following function that compares at most n bytes beginning with s2 with the cor- responding bytes beginning with s1, where n is the number of bytes that s2 has to be incremented before it points to the null character \0. If all n bytes match, the function should return 0; otherwise, it should return either -1 or 1 according to whether the byte from s1 is less than or greater than the byte from s2 at the first mismatch: int cmp(char* s1, char* s2).

2. Write the following function that searches the n bytes beginning with s for the character c, where n is the number of bytes that s has to be incremented before it points to the null char- acter '\0'. If the character is found, a pointer to it is returned; otherwise return NULL:
char* chr(char* s, char c).

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Write the following function that compares at most n bytes
Reference No:- TGS01186338

Now Priced at $10 (50% Discount)

Recommended (96%)

Rated (4.8/5)