Log in

View Full Version : need help with argv[i] (c++ command line parameters)


E-Male
30th May 2004, 00:27
i got a problem (again) with my current c++ project
i try to use command line parameters, which seemd quite easy with argc and argv[i]
BUT when i try something like this:
if (argv[i]=="abc") ...
it's false, even if the parameters is abc
does anyone know a (simple) way to check if a certain parameter is there?
thx in advance
E-Male

Moitah
30th May 2004, 00:40
You are comparing pointers, not the actual strings. You need to do:
if (strcmp(argv[i], "abc") == 0) ...

EDIT: Or stricmp for case-insensative comparison.

E-Male
30th May 2004, 03:17
thx a lot
just the info i needed

got the first working alpha of my code ready now