This returns an error:
return (arg[0] == "-" && arg[1] == "-") ? true : false;
error: ISO C++ forbids comparison between pointer and integer
However, this does not:
return (arg[0] == '-' && arg[1] == '-') ? true : false;
What is the difference between ' and " ?
Single-quotes denote a character literal. Double-quotes denote a string literal.
So
'-'is of typechar1, whereas"-"is of typeconst char[2](which typically decays toconst char *).1
intin C.