Question
The program needs to be written in C. Write a function void camelCase(char* word) where word consists of more than two words separated by underscore
The program needs to be written in C.
Write a function void camelCase(char* word) where word consists of more than two words separated by underscore such as random_word or "hello_world_my_name_is_sam". camelCase() should remove underscores from the sentence and rewrite in lower camel case (https:// en.wikipedia.org/wiki/Camel_case). Watch out for the end of the string, which is denoted by \0. You have to ensure that legal strings are given to the camelCase() function.
NOTE: You can use the toUpperCase(...) a function provided in the skeletal code to change the case of a character from lowercase to upper case . Notice that toUpperCase() assumes that the character is currently in lower case. Therefore, you would have to check the case of a character before calling toUpperCase().
Here's the skeletal code:
#include
/*converts ch to upper case, assuming it is in lower case currently*/ char toUpperCase(char ch){ return ch-'a'+'A'; }
void camelCase(char* word){ /*Convert to camelCase*/ }
int main(){ /*Read the string from the keyboard */ /*Call camelCase*/ /*Print the new the string */ return 0; }
Example: if you typed in "hello_world_my_name_is_sam" the output should be "helloWorldMyNameIsSam"
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