I am attempting at making a vending machine in c++. I am simply trying to add some validation to it so it wont break. I first ask the user to input the first two letters of their choice. I know i cant stop them from entering more then one char. I created a do while loop to make sure the first char and the second character aren't bigger then the maxChar. I am getting no syntactical error, but im not getting the correct answer. I know that a char is different then an int, but how would i convert the char to ints? any help would be greatly appreciated
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <set>
#include <cctype>
#include <locale>
const int maxChr = 3;
char chrOne,chrTwo;
do
{
cin >>chrOne>>chrTwo;
if(chrOne + chrTwo > maxChr)
{
cout <<"you have too many characters"
"please try again" << endl;
}
while (chrOne + chrTwo > maxChr);
}