ここでは、std::string から 1 つの* 疑問符 ('?') を見つける方法を示します。コメントを必ず読んでください。
int main( void )
{
// DECLARE LOCAL VARIABLES
// Declare strA as std::string
std::string strA = "";
// Declare nIndex as int. We set the value of it to -1 to let us know
// if there were any '?' within strA
int nIndex = -1;
// INITIALIZE
// Set the value of strA to the line that was inputted
// You might want to loop this until the length of strA
// is greater than 0
std::getline( std::cin, strA );
// SEARCH FOR THE FIRST '?'
// if std::string::find returns -1, then no '?' was found within strA
nIndex = strA.find( '?' );
// CHECKING AND PRINTING nIndex
// Remember why strA is -1?
if( nIndex == -1 )
std::cout << "The inputted string does not contain any '?'...\n";
else std::cout << "The first '?' is found at: " << nIndex;
// DONE
#ifdef DEBUG
std::cout << "\nDebugging > Paused! Enter any key to continue...\n";
::getchar( );
#endif // DEBUG
return( 0 );
};