Bugfix & Makefile

master
Atlas Cove 7 months ago
parent 244862feea
commit 420b78bdc2
  1. 8
      Makefile
  2. 4
      add.c
  3. 4
      div.c
  4. 4
      mul.c
  5. 4
      sub.c

@ -0,0 +1,8 @@
files = add div mean mul sub sum
all: $(files)
$(files): %: %.c
clean:
rm -v $(files)

@ -13,10 +13,10 @@ int main(int argc, char **argv) {
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);
eprintf("%s: argument 1 cannot be parsed as int", *argv);
return 1;
} else if(e2==EOF) {
eprintf("%s: argument %d cannot be parsed as int", *argv);
eprintf("%s: argument 2 cannot be parsed as int", *argv);
return 1;
}
out=v1+v2;

@ -13,10 +13,10 @@ int main(int argc, char **argv) {
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);
eprintf("%s: argument 1 cannot be parsed as int", *argv);
return 1;
} else if(e2==EOF) {
eprintf("%s: argument %d cannot be parsed as int", *argv);
eprintf("%s: argument 2 cannot be parsed as int", *argv);
return 1;
}
out=v1/v2;

@ -13,10 +13,10 @@ int main(int argc, char **argv) {
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);
eprintf("%s: argument 1 cannot be parsed as int", *argv);
return 1;
} else if(e2==EOF) {
eprintf("%s: argument %d cannot be parsed as int", *argv);
eprintf("%s: argument 2 cannot be parsed as int", *argv);
return 1;
}
out=v1*v2;

@ -13,10 +13,10 @@ int main(int argc, char **argv) {
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);
eprintf("%s: argument 1 cannot be parsed as int", *argv);
return 1;
} else if(e2==EOF) {
eprintf("%s: argument %d cannot be parsed as int", *argv);
eprintf("%s: argument 2 cannot be parsed as int", *argv);
return 1;
}
out=v1-v2;

Loading…
Cancel
Save