jagomaniak wrote:
> Ok, I've tried to put something together from the tutorials on the web
> and ended up using this, which works:
>
> char *c = argv[2];
>
> for (c == argv[argc - 2]; *c != '\0'; c++)
c == argv[argc - 2] does nothing (or worse, crashes). The compiler
should be complaining - turn up the warning level so that it does.
> if ((islower(*c)) || (isspace(*c)) || (ispunct(*c)))
> {
> printf("\nWrong characters in parameter!\n");
> return EXIT_FAILURE;
> }
>
> However, it conflicts with my other conditions for the command line,
> namely this:
>
> if (argc == 2 && strcmp("-h", argv[1]) == 0)
> {
> return help();
> }
>
> It somehow doesn't like that the second parameter is not there. Under
> linux, I get the error 'Segmentation fault: 11 (core dumped)'.
>
> Any ideas?
What was wrong with my suggestion?
You should be testing argc for the proper number of parameters before
doing anything else.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/