Hi again people. I am stuck on this array that converts lower case letters to upper case letters. I need to find out how to make it not display strange characters after the letters are entered. I know it has something to do with the 'null' terminator, but I am lost in how to implement it. I also have to have it parallel instead of perpendicular. Here s my code:
#include <iostream>
#include <cstring>
using namespace std;
void cStringToUpper(int numLetters, char letters[]);
const int numLetters = 11;
int main()
{
char letters[numLetters]; //character array
char cont;
do
{
cout << "Please enter up to 11 letters." << endl;
cStringToUpper(numLetters,letters);
cout << " " << endl;
cout << "Do you wish to enter in another set of"
"letters?\n"
"Press 'Y' to continue or 'Q' to end the program"
<< endl;
cin >> cont;
cout << "\n" << endl;
cin.ignore(200,'\n');
}
while(cont == 'y' || cont == 'Y');
return 0;
}
void cStringToUpper(int numLetters, char letters[])
{ /*This function will take the users input of letters and convert
those letters into a uppercase format.
Input: numLetters, letters[] array.
Output: The character type in uppercase format.
Asumptions: that they enter in a valid character type.
*/
int loopCount;
cin.getline(letters, numLetters);
cout << "\n" << endl;
cout << "Lowercase" << "\t" << "Uppercase\n";
cout << "---------" << "\t" << "----------\n";
for (loopCount= 0;loopCount < numLetters;loopCount++)
{
cout << " " << letters[loopCount] << "\t\t";
if((letters[loopCount]>=97) &&(letters[loopCount] <=122))
letters[loopCount]-=32;
cout << " " << letters[loopCount]
<< endl;
}
}
Any help would be great.