# C++: C-Strings - Programming Exercises 1

## Programming problems

1. Write a `myStrlen` function which is the same as the library `strlen` function. Assume the prototype is

           int myStrlen(char a[]);
           int myStrlen(char* a);

2. Write the `myStrcpy` function which is the same as the library `strlen` function. Assume the prototype is

           void myStrcpy(char a[], char b[]);
           void myStrcpy(char* a, char* b);

3. Write the `myStrcat` function which is the same as the library `strlen` function. Assume the prototype is

           void myStrcat(char a[], char b[]);
           void myStrcat(char* a, char* b);

4. Write the `myStrcmp` function which is the same as the library `strlen` function. Assume the prototype is

           int myStrcmp(char a[], char b[]);  // array version
           int myStrcmp(char* a, char* b);    // pointer version

   For example,

                i = myStrcmp("abc", "after");  // result is a negative value

   There is a slight twist to this problem. The standard allows each compiler to decide if the `char` type is signed or not, so the range of of a `char` is either -128..127 (signed) or 0..255 (unsigned). To do the comparison properly, the comparison should be done on the unsigned characters, which requires casting to that type.

## Guidelines for problems

- No I/O (`cin` or `cout`) should be in these functions (other than temporary I/O for debugging purposes). As a general design principle, I/O should be restricted to a few functions which are specifically used for this purpose. There is no need for I/O in these functions.
- No function need to allocate space for temporary arrays. The arrays which are passed as parameters are sufficient.
- These functions can be written in either array-style or pointer-style.