commit babf9498d5a13a58a57e5fea838a9f8436b9c74e
parent 843fbbf9ac42584b8827d17c704b3b89fe687d53
Author: Tyler Clark <tyler.clark@foxide.xyz>
Date: Sun, 9 Feb 2025 21:42:27 -0500
Finished head
Diffstat:
1 file changed, 13 insertions(+), 18 deletions(-)
diff --git a/src/head.c b/src/head.c
@@ -1,12 +1,5 @@
-/*
- * ARGUMENTS
- * =========
- * -c, --bytes: prints specified number of bytes
- * FINISHED: -n, --lines: Prints specified number of lines
- * =========
- * FINISHED: if there are multiple files specified ==> foo <== will be printed before
- * the lines in each file, where foo is the name of the file.
- */
+/* Terrible implementation of the false core util */
+/* For license infomration see the LICENSE file included in this repo */
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
@@ -21,9 +14,7 @@ int main(int argc, char *argv[]) {
int argByte = strcmp(argv[1], "-c");
if (argByte == 0) {
- printf("Some stuff would happen here\n");
int bytes = strtol(argv[2], NULL, 10);
- printf("It would print %d bytes\n", bytes);
files = 3;
if (files == (argc - 1)) {
fp = fopen(argv[files], "r");
@@ -34,14 +25,18 @@ int main(int argc, char *argv[]) {
}
return 0;
} else {
- fp = fopen(argv[files], "r");
- i = 0;
- while(((ch = fgetc(fp)) != EOF) && (i < bytes)) {
- printf("%c", ch);
- i++;
+ for (files = files; files < argc; files++) {
+ fp = fopen(argv[files], "r");
+ i = 0;
+ printf("==> %s <==\n", argv[files]);
+ while(((ch = fgetc(fp)) != EOF) && (i < bytes)) {
+ printf("%c", ch);
+ i++;
+ }
+ fclose(fp);
}
- return 0;
- }
+ return 0;
+ }
}
int argLine = strcmp(argv[1], "-n");