Quote (Richter @ Oct 11 2012 05:05pm)
strlen(card)
this.
if strlen returns greater then 1 its invalid input
id also use the tolower() or toupper() function so that all your card inputs are the same so you dont have to use case switches that fall through to get the same output. would eliminate the need for upper and lower case case switches
you could also use a file streaming function to get input from STDIN but limit it to 1 character. the function fgets() comes to mind where you can supply a file descriptor (STDIN), a character buffer (array of characters), and a character limit (int) and fgets will read input from STDIN and put the data into the character buffer until it reaches the limit or it encounters a newline character which ever comes first.
although im sure c++ has a built in string function to do this or limit the amount of characters somehow.
i think string.substring() would work ( switch(card.substring(0,1) ) assuming you are using c++ strings, but would be a hack patch job for the real error of reading in to many characters.
This post was edited by AbDuCt on Oct 11 2012 09:06pm