Up through ex8

This commit is contained in:
Dan Buch 2024-04-16 08:17:54 -04:00
parent 7da7228911
commit af95125894
Signed by: meatballhat
GPG Key ID: A12F782281063434
3 changed files with 27 additions and 5 deletions

1
lcthw/.gitignore vendored
View File

@ -1,3 +1,4 @@
ex1
ex3
ex7
ex8

View File

@ -1,6 +1,6 @@
CFLAGS ?= -Wall -g
GDBRUN = gdb --batch --ex run --ex bt --ex q --args
BUILD_TARGETS = ex1 ex3 ex7
BUILD_TARGETS = ex1 ex3 ex7 ex8
.PHONY: all
all: build test
@ -14,10 +14,10 @@ build: $(BUILD_TARGETS)
.PHONY: gtest
gtest:
$(foreach bt,$(BUILD_TARGETS),$(GDBRUN) ./$(bt) &&) \
echo gyay
@$(foreach bt,$(BUILD_TARGETS),$(GDBRUN) ./$(bt) &&) \
echo ' gYAY'
.PHONY: test
test:
$(foreach bt,$(BUILD_TARGETS),./$(bt) &&) \
echo yay
@$(foreach bt,$(BUILD_TARGETS),./$(bt) &&) \
echo ' YAY'

21
lcthw/ex8.c Normal file
View File

@ -0,0 +1,21 @@
#include <stdio.h>
int main(int argc, char* argv[])
{
int i = 0;
if (argc == 1) {
printf("You no argument.\n");
} else if (argc > 1 && argc < 4) {
printf("Here's your arguments:\n");
for (i = 0; i < argc; i++) {
printf("%s ", argv[i]);
}
printf("\n");
} else {
printf("You have too many arguments.\n");
}
return 0;
}