32 lines
654 B
C
32 lines
654 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int test(int a, int b) {
|
|
if (a + b >= 1000) {
|
|
fprintf(stderr, "CRITICAL ERROR!!!\n");
|
|
exit(1);
|
|
}
|
|
|
|
return a + b;
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
if (argc < 3) {
|
|
fprintf(stderr, "Usage: %s <a> <b>\n", argv[0]);
|
|
exit(1);
|
|
}
|
|
|
|
int a, b;
|
|
if (EOF == sscanf(argv[1], "%d", &a)) {
|
|
fprintf(stderr, "%s is not a valid integer\n", argv[1]);
|
|
exit(1);
|
|
}
|
|
|
|
if (EOF == sscanf(argv[2], "%d", &b)) {
|
|
fprintf(stderr, "%s is not a valid integer\n", argv[2]);
|
|
exit(1);
|
|
}
|
|
|
|
fprintf(stdout, "%d\n", test(a, b));
|
|
return 0;
|
|
} |