Question
Recall, a C-string is a null-terminated character array. The null characters preceding the null terminator ('0') are considered to be the characters of the string.
Recall, a C-string is a null-terminated character array. The null characters preceding the null terminator ('\0') are considered to be the characters of the string.
For example, the word "hello" would be stored in a char array of size six or bigger and the initial six characters would be 'h', 'e', 'l', 'l', 'o', '\0'.
Any array elements after the null terminator are ignored.
To get familiar with C-strings, write the following functions:
int getLength(const char w[]); // return the length of the C-string (excluding the null-terminator)
void toUppercase(char w[]); // change any lowercase letters 'a' to 'z' to uppercase 'A' to 'Z'.
bool equal(const char v[], const char w[]); // return true if v and w contain the same characters in same order, up to and including null terminators
void copy(char destination[], const char source[]); // copy source into destination including the null terminator. Assume the underlying array for destination is big enough to hold all the characters of source.
void removeLeadingSpaces(char w[]); // remove any leading spaces from w e.g. " hello" --> "hello". If w only contains spaces then a null terminator will be assigned to w[0], so " " --> "".
char * getPointerToFirstNonSpace(const char w[]); // return a pointer to the first character that's not a space.
int countVowels(const char w[]) ; // return the number of vowels in w, where a vowel is 'a' , 'e', 'i' , 'o' or 'u' (We're not counting 'y' as a vowel.)
bool comesBefore(const char v[], const char w[]); // return true if v comes before w in dictionary order. The means compare character by character and return true or false based on first nonmatching character. If all character match, return false.
Upload your functions along with a main that tests them
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