So I\'m attempting to check the arguments that I\'m inputting into my program, and one of them is either the word \"yes\" or \"no\", entered without the quotes.
I\'
Modern C++, with a bit of const correctness...
/*BINFMTCXX: -Wall -Werror -std=c++17
*/
#include
#include
#include
using std::string; using std::vector; using std::cerr;
int main( int argc, char * const argv[] )
{
assert( argc >= 1 ); // exploratory -- could fail in principle, but not really
const vector args(argv+1,argv+argc); // convert C-style to modern C++
for ( auto a : args ) cerr<<(a=="yes")<<"\n"; // operator '==' works as expected
}
Note: The standard doesn't guarantee that you can use const in the signature of main, nor does it forbid it.
As used here, const ensures that we won't change things we don't intend to change -- which is the purpose of const in the C++ language.
See also...
argc