From d603e00836c852d7b73964e3a767497080e067d7 Mon Sep 17 00:00:00 2001 From: William Culhane Date: Fri, 4 Jun 2021 11:32:49 -0600 Subject: [PATCH] lab5: Start assignment --- labs/lab5/.gitignore | 1 + labs/lab5/Makefile | 17 +++++++++++++++++ labs/lab5/lab5.cpp | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 labs/lab5/.gitignore create mode 100644 labs/lab5/Makefile create mode 100644 labs/lab5/lab5.cpp diff --git a/labs/lab5/.gitignore b/labs/lab5/.gitignore new file mode 100644 index 0000000..16eaa20 --- /dev/null +++ b/labs/lab5/.gitignore @@ -0,0 +1 @@ +/lab5 diff --git a/labs/lab5/Makefile b/labs/lab5/Makefile new file mode 100644 index 0000000..8c46899 --- /dev/null +++ b/labs/lab5/Makefile @@ -0,0 +1,17 @@ +.PHONY: all clean + +PROG = lab5 +SOURCES = $(wildcard *.cpp) +OBJ = $(SOURCES:%.cpp=%.o) + +all: $(PROG) + +$(PROG): ${OBJ} + g++ -o $@ $^ -Wall + +%.o: %.c + g++ -c -o $@ -Wall $^ + +clean: + rm -f $(OBJ) + rm -f $(PROG) diff --git a/labs/lab5/lab5.cpp b/labs/lab5/lab5.cpp new file mode 100644 index 0000000..d1d678f --- /dev/null +++ b/labs/lab5/lab5.cpp @@ -0,0 +1,32 @@ +#include +#include + +using namespace std; + +/* + * William Culhane + * Lab 5, CSCI 112 + * Fri Jun 4 10:46:06 AM MDT 2021 + */ + +int main(int argc, char **argv) { + if (argc != 2) { + cerr << "Invalid number of argument\n"; + return 1; + } + + char* raw_num = argv[1]; + + unsigned int raw_num_length; + + for (unsigned int i = 0; i < 4; i++) { + if (raw_num[i] == 0) { + raw_num_length = i + 1; + break; + } + } + + cout << raw_num_length; + + return 0; +} -- 2.45.2