access to std::string element

I am trying to parse args.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void CLParser::ParseArgs(int argc, char* argv[]){
	std::string arg;
for (std::vector<std::string>::iterator it = raw_args.begin(); it != raw_args.end(); ++it)
	{
		i++;
		arg=(*it);
if (i == 1 && (*it) != "-r" ){}
// FAILS HERE:
if (i == 2 && (*it)[0] != "-" ){
			}
...
// BELLOW IS WORKING:
if ( (*it)[n] != '{' ) ...

	}
}


ERROR:
error C2040: '!=' : 'int' differs in levels of indirection from 'const char [2]'

I tried both:
(*it)[0] or arg[0] and both gives error. How to compare the character?
"-" is a string.
'-' is a char.
Last edited on
Why this works?
1
2
3
4
5
6
7
int length = (*it).length();
for (int n=0; n<length; n++){
	if (prefixProc)
		{
		if ( (*it)[n] != '{' ){}
		}
}

Should not this fail?
Last edited on
Corrected, thanks

if (i == 2 && (*it)[0] != '-' )
Topic archived. No new replies allowed.