I would try it this way:
#include <iostream>
static int is_valid_function_name(const char *function_name_string){
for( ; *function_name_string !='\0' ; function_name_string++ ){
switch (function_name_string[0]) {
case '?' :
case '/' :
case '\\' :
case ':' :
case '*' :
case '<' :
case '>' :
case '\"' :
return 0;
default:
break;
}
}
return 1;
}
int main() {
const char * legal_string = "there are no special characters";
const char * non_legal_string = "there are special < characters ?";
std::cout << "\"" << legal_string;
if ( is_valid_function_name( legal_string ) )
std::cout << "\" is a valid function name" << std::endl;
else
std::cout << "\" is not a valid function name" << std::endl;
std::cout << "\"" << non_legal_string;
if ( is_valid_function_name( non_legal_string ) )
std::cout << "\" is a valid function name" << std::endl;
else
std::cout << "\" is not a valid function name" << std::endl;
return 0;
} K.