- Write a function to remove all trailing blanks from the right end of a string.
Assume the prototype is
void trimRight(char a[]);
- Write a function to remove all leading blanks from the left end of a string.
Assume the prototype is
void trimLeft(char a[]);
- Write a function to add extra blanks to the right end of a string to
make it at least length n. If the string is already n characters or longer,
do not change the string.
Assume the prototype is
void padRight(char a[], int n);
- Write a function to add extra blanks to the left end of a string to
make it at least length n. If the string is already n characters or longer,
do not change the string.
Assume the prototype is
void padLeft(char a[], int n);
- Write a function to center a string by adding blanks to the front and back.
If the string is already n characters or longer,
do not change the string. If an odd number of blanks have to be added,
put the extra blank on the right. You can use the functions in the
previous problems (padRight and padLeft) to solve this problem.
Assume the prototype is
void center(char a[], int n);
- Write a function which returns non-zero (ie, true) if the string parameter
is a palindrome. A palindrome is any "word" which is the same
forward and backward, eg, radar, noon, 20011002... The function should return
0 if the argument is not a palindrome.
Assume the prototype is
int isPalindrome(char a[]);
- Write a function which shortens a string to n characters. If the string is
shorter than n, the function should not change the string.
Assume the prototype is
void truncate(char a[], int n);
- Write a function which capitalizes the first letter in every word.
Assume the first letter is any letter at the beginning or preceded
by a blank. All other letters should be turned into lowercase.
You can use the library toupper and tolower functions.
Assume the prototype is
void capitalizeWords(char a[]);
Solutions: