strcmp multiparam second opinion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DavidKrutsko
    New Member
    • Aug 2007
    • 13

    #1

    strcmp multiparam second opinion

    Greetz,

    i just need a second hand opinion from other people....

    say i have a function [-Encrypt Key] but the Key part is optional....

    the way i have it layed out now is

    Code:
    if (strcmp (argv[i+1], "-InFile /*or another argument*/) == 0)
    so basically check next argument to see if its another argument instead of the key.... if it is then use defualt key, if not then read it and go to next argument....

    but i have like 6 arguments and i DO NOT wish to do the following

    Code:
    if (strcmp (argv[i+1], "-InFile") && strcmp (argv[i+1], "another argument) && and so on)
    is there some shortcut or am i stuck with doing this....
    i already know about "va_" functions and sprintf but they dont help....

    thanks,

    DK--
  • DavidKrutsko
    New Member
    • Aug 2007
    • 13

    #2
    solved!!!

    make key optional by issuing it a defauly parameter then checking to see if its NULL or not... if yes then read it if its NULL then ignore and more on....

    Comment

    Working...