moving from gitlab

This commit is contained in:
2026-05-15 13:26:54 -04:00
commit 7391c21087
33 changed files with 2539 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
#include <stdio.h>
FILE *openFile(const char *filename);
void catFile(FILE *file);
int main(int argc, char *argv[]) {
if (argc != 2) {
printf("error: missing file\nusage: cat <filename>\n");
return -1;
}
FILE *file = openFile(argv[1]);
if (!file) {
printf("error: file (%s) not found\n", argv[1]);
return -2;
}
catFile(file);
fclose(file);
return 0;
}
FILE *openFile(const char *filename) {
FILE *file;
file = fopen(filename, "r");
return file;
}
void catFile(FILE *file) {
char buf[512];
while (fgets(buf, 512, file)) {
printf("%s", buf);
}
}