shellmath/div.c

26 lines
499 B
C
Raw Normal View History

2022-05-07 08:22:36 -04:00
#include <stdio.h>
#ifndef eprintf
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
int main(int argc, char **argv) {
int v1;
int v2;
int out;
int e1;
int e2;
e1 = sscanf(argv[1], "%i", &v1);
e2 = sscanf(argv[2], "%i", &v2);
if(e1==EOF) {
eprintf("%s: argument %d cannot be parsed as int", *argv);
return 1;
} else if(e2==EOF) {
eprintf("%s: argument %d cannot be parsed as int", *argv);
return 1;
}
out=v1/v2;
printf("%d\n",out);
return 0;
}