Greetings all!~ I'm a newb when it comes to C++ and could use a bit of help with this code. It is supposed to take any character input, store it in array and then if there are lower case letters make them upper case. After if goes through the first run, it is supposed to again prompt for another set of characters. If Q is entered the program exits. As far as I can tell it runs fine until Q is pressed. It prints Q then again prompts for an input. I've been working on this for going on 18hours straight so any help would be greatly appreciated. And before I'm told I can use library functions as toupper and such, the assignment is to do it with math operators, and compare every letter for lowercase against ascii before moving onto the next :)
Thanks again guys (and ladies)
#include <string>
#include <iostream>
using namespace std;
const int MAX = 11;
int getInput();
char arrayInput[MAX];
void cStringToUpper (char[MAX]);
const char SENTINEL[MAX] = "Q";
char arrayOutput[MAX];
int main()
{
getInput();
return 0;
}
int getInput()
{
cout << "\n" << "Get Input: ";
cin >> arrayInput;
while (arrayInput != SENTINEL)
{
cStringToUpper(arrayInput);
}
cout << "Goodbye!~";
exit(0);
cin.ignore(2);
return 0;
}
void cStringToUpper (char arrayInput[])
{
char arrayOutput[MAX];
int size=0;
int j = 0;
while (arrayInput[size] != '\0')
{ size++; }
while (arrayInput[j] != '\0')
{
if ((arrayInput[j] >= 97) && (arrayInput[j] <= 122))
{
//if ((arrayInput[j] >= 97) && (arrayInput[j] <= 122))
//{
arrayOutput[j] = arrayInput[j]-32;
}
else
{
arrayOutput[j] = arrayInput[j];
}
j++;
}
for (int i = 0; i<size; i++)
{
cout << arrayOutput[i];
}
getInput();
}