Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
Krasimir committed Nov 25, 2024
1 parent abbdfc8 commit 826d9b4
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions assignment.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,21 @@ int is_positive_integer(const char *str) {
}

int main(int argc, char *argv[]) {
if (argc == 1) {
printf("Incorrect usage. You provided 0 arguments. The correct number of arguments is 2\n");
return 1;
} else if (argc == 2) {
printf("Incorrect usage. You provided 1 arguments. The correct number of arguments is 2\n");
return 1;
} else if (argc > 3) {
printf("Incorrect usage. You provided 3 arguments. The correct number of arguments is 2\n");
if (argc != 3) {
printf("Incorrect usage. You provided %d arguments. The correct number of arguments is 2\n", argc - 1);
return 1;
}

if (!is_positive_integer(argv[1]) || !is_positive_integer(argv[2])) {
printf("Incorrect usage. The parameters you provided are not positive integers\n");
printf("Incorrect usage. You provided %d arguments. The correct number of arguments is 2\n", argc - 1);
return 1;
}

int rows = atoi(argv[1]);
int cols = atoi(argv[2]);

if (rows <= 0 || cols <= 0) {
printf("Incorrect usage. Dimensions must be positive integers\n");
printf("Incorrect usage. You provided %d arguments. The correct number of arguments is 2\n", argc - 1);
return 1;
}

Expand Down

0 comments on commit 826d9b4

Please sign in to comment.