Bugfix & Makefile

This commit is contained in:
Atlas Cove 2022-05-07 13:36:37 +01:00
parent 244862feea
commit 420b78bdc2
5 changed files with 16 additions and 8 deletions

8
Makefile Normal file
View File

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

4
add.c
View File

@ -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;

4
div.c
View File

@ -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;

4
mul.c
View File

@ -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;

4
sub.c
View File

@ -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;