- Write a function
void printArray(int *arr, int size)that outputs all of the integers in the passed array. - Write a function
int * sort(int *arr, int size)that returns anew-allocated copy ofarrin sorted order ({3, 1, 2} -> {1, 2, 3}). - As the size
Nincreases, how would you characterize the amount of time yoursortfunction takes? That is, does it look like it's proportional toN,N^2,N^3, or something else? Determine this without measuring.
See strings.md for an overview of C/C++ strings.
Do the following without using C++ std::strings:
- Write a function
int strLength(const char *s)that counts the number of characters in a string. (hint: remember that a C string ends at the 0) - Write a function
void strTruncate(char *s, int n)that truncates the passed string to the given length. (hint: this is a single line of code) - Write a function
void strCapitalize(char *s)that capitalizes the passed string's ASCII lowercase characters to their uppercase equivalents. (hint:man ascii) - Write a function
void strCopy(char *s1, const char *s2)that makess1contain the same characters ass2. Put a comment above this function explaining what is horribly, horribly wrong about it. - Write a function
void strAppend(char *s1, const char *s2)that appends the contents ofs2tos1. Put a comment above this function explaining what is horribly, horribly wrong about it. - Write a program
int main(int argc, char **argv)that does the following:- Checks that
argc >= 2, and exits without doing anything fun if it isn't - Copies
argv[1](the first argument passed to your program!) into a localchar name[10] - Truncates
nameto at most six characters - Stores a greeting of the form "hello, name!" into a
char greeting[40] - Outputs in one of two ways:
- If the name is exactly three characters long, shouts the greeting in all
uppercase letters using
printf("%s\n", greeting) - Otherwise, just greets normally:
printf("%s\n", greeting)
- If the name is exactly three characters long, shouts the greeting in all
uppercase letters using
- Checks that