Skip to main content
2 of 2
added 59 characters in body
Blauelf
  • 21k
  • 2
  • 13
  • 22
  1. You are meant to reject any number of command-line arguments other than one (means argc should be 2).

  2. To test whether a given character is numeric/alphabetic, you can use the isdigit/isalpha function (actually implemented as a macro, so mistakes in code might show up in weird ways), like if (isalpha(argv[1][j])). Or, test a range, like if (argv[1][j] >= '0' && argv[1][j] <= '9') or if (argv[1][j] >= 'A' && argv[1][j] <= 'Z' || argv[1][j] >= 'a' && argv[1][j] <= 'z') (&& has precedence over || like * has over +). If you want to negate that last expression without some ! in front of everything, have fun with De Morgan's laws (it looks worse than it is). And keep in mind that non-alphabetic does not mean numeric or the other way around. Punctuation is neither nor. So test for good or non-good, not specific bad characters.

  3. On hitting a "bad" character and printing a usage notice, return with the required exit code, returning will automatically abort any loops you're in, any code left. On hitting a "good" character, there's no immediate action associated. After your loop, you would know the whole word is right.

Blauelf
  • 21k
  • 2
  • 13
  • 22