63 203
Assignments Done
99,3%
Successfully Done
In July 2018

Answer to Question #12496 in C# for Nora

Question #12496
Write the C function int camelCase(char * text) to transform any string made of words separated by spaces in CamelCase format, that is, converting to uppercase the first character of all words, converting all remaining characters of a word to lowercase and removing all spaces .
Expert's answer
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main()
{
char str[100];
printf("Input a string: ");
do
{
& gets(str);
} while(!str[0]);
camelCase(str);
printf("String in camelCase: %s",str);
return 0;
}

int camelCase(char *text)
{
int i;
char *p;
char str[100] = "";
p = strtok(text," ");
while (p != NULL)
{
& p[0] = toupper(p[0]);
& for (i=1;p[i];i++)
& {
p[i] = tolower(p[i]);
& }
& strcat(str,p);
& p = strtok(NULL," ");
}
strcpy(text,str);
text[0] = tolower(text[0]);
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions