//Natalie Zarate CSC 5 Chapter 10, P.589, #5
/*******************************************************************************
* CORRECT CAPITALIZATION
*
* This program will prompt the user for a sentence with improper lowecase use.
* Then, it will correct the lowercases, if neccessary, and display the
* corrected sentence.
* _____________________________________________________________________________
* INPUT
* sentence - user inputed sentence
*
* OUTPUT
* (corrected) sentence - user inputted sentence with correct capitalization
* ****************************************************************************/
#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;
/*******************************************************************************
* Capitalize
*
* This program with take the given sentence and fixes improper lowercases
* _____________________________________________________________________________
* INPUT
* string - user inputted sentence
* ****************************************************************************/
// Prototype for capitalize
void Capitalize (char *string);
int main()
{
char sentence[51];
// Propmpt user for sentence
cout << "Enter a sentence (50 character limit):" << endl;
cin.getline(sentence, sizeof(sentence));
// Call Capitalize
Capitalize(sentence);
// Display sentence with proper capitalization
cout << "Fixed Sentence: " << sentence << endl;
return 0;
}
void Capitalize(char *string)
{
bool capital = true; // Flag to indicate if letter needs to be capitalized
// Step through array
while (*string)
{
if (capital && isalpha(*string))
{
//Capitalize the character
*string = toupper(*string);
//Tell program that letter is now uppercase
capital = false;
}
string++;
}
}