> My program is run in the command line with two parameters:
>
> program -param1 param2

This is a C answer, it may be slightly different in C++.

If you declare

  int main(int argc, char *argv[])

you should first check that argc == 3 and exit with a 
suitable error message if not. With argc ==  3, you can 
access argv[0] (program name), argv[1] (param1 string), 
argv[2] (param2 string).

BTW argc and argv can have any names you like but these are 
the conventional ones (for argument count and argument 
vector).

> I need the program to check if the param2 includes any 
> characters
> other than capital letters (A-Z) and numbers (0-9).

Loop through argv[2] until you reach the terminating '\0', 
applying the "is" functions of <ctype.h> to each char. Or 
you could do it the long way and compare each char with 'a', 
'z', '0', '9'.

Good luck!

David

Reply via email to