Heya, I was hoping you guys could help me with some novice programming woes. I'm trying to parse command-line options (I want to write the parser myself for the experience), and somehow am stuck up on... well... I dunno, but it's not working.
<br><br>The logic in my code is comparable to the following sample:<br><br>---------------------------<br><br>#include <iostream><br><br>using namespace std;<br><br>int main( int argc, char *argv[] )<br>{<br> for (int i = 1; i < argc; i++)
<br> {<br> cout << "*Debug: Parsing(" << argv[i] << ")" << endl;<br> if (argv[i] == "greetings")<br> {<br> cout << "Found: greetings" << endl;
<br> }<br> else if (argv[i] == "g")<br> {<br> cout << "Found: g" << endl;<br> }<br> else<br> {<br> cout << "Invalid" << endl;
<br> }<br> }<br> return 0;<br>}<br><br>---------------------------<br><br>The above compiles fine with GCC v4.0.1 into a binary named "sandbox". But when I run it:<br><br>---------------------------
<br><br>$ ./sandbox greetings<br>*Debug: Parsing(greetings)<br>Invalid<br>*Debug: Parsing(g)<br>Invalid<br><br>---------------------------<br><br>I though I had something working earlier, but whatever I changed broke it. Help?
<br><br>SigmaX<br clear="all"><br>-- <br>My home page: <a href="http://www.SigmaX.org">http://www.SigmaX.org</a><br><br>"ttocs laeno cire oshkosh b'gosh fyedernoggersnodden nicht stein bon probiscus"<br><br>"Education is what remains after one has forgotten everything he learned in school"
<br> -- Albert Einstein