There's plenty wrong with this, mostly in your prototype and definition. Then there's the fact that FALSE and TRUE haven't been defined. Try something like this:
Code:
#include <iostream>
char getChoice ( const char *valid )
{
char c = 0;
bool done = false;
while ( !done && std::cin.get ( c ) ) {
for ( const char *p = valid; *p != '\0'; p++ ) {
if ( c == *p ) {
done = true;
break;
}
}
}
return c;
}
int main()
{
std::cout<< getChoice ( "ABCabc" ) <<std::endl;
}
Or if you can stand using the STL:
Code:
#include <iostream>
#include <algorithm>
char getChoice ( const char *valid, int size )
{
char c;
const char *end = valid + size;
while ( std::cin.get ( c ) ) {
if ( std::find ( valid, end, c ) != end )
return c;
}
return 0; // Or another suitable failure value
}
int main()
{
std::cout<< getChoice ( "ABCabc", 6 ) <<std::endl;
}