C++ :: Replacing Word In Char Array
Jul 29, 2014I'm writing a function that accepts a char array containing the title of a book as parameter, the following then has to take place:
1.) Extra white spaces between words need to be removed [DONE]
2.) Text has to be converted to title case, i.e each new word has to start with a capital letter [DONE]
3.) Lastly I have I text file (minors.txt) containing a number of words that should not be capitalized by the function, like "a" and "an", however I don't know how to implement this.
Example of end product:
ENTER THE TITLE OF THE BOOK: a brief hisTOry OF everyTHING
Correct Output:
bool Book :: convertToTitleCase(char* inTitle) {
int length = strlen(inTitle);
bool thisWordCapped = false;
//Convert paramater to lower case and
//Remove multiple white spaces
for (int x = 0; x < length; x++)
[Code]...
I was thinking of maby reading the words in the text file into a string array, and then comparing the two arrays to ensure that when a word is present in a text file, the word is not capitalized, however I don't know if that is possible between a string array and a char array.