Implement file opening
This commit is contained in:
parent
97a99175f4
commit
e2ed5aca4d
4
Makefile
4
Makefile
@ -9,10 +9,10 @@ CC=cc
|
||||
CFLAGS=-I$(IDIR) -Wall -Wextra -pedantic
|
||||
LIB=
|
||||
|
||||
_DEPS=
|
||||
_DEPS=lib.h
|
||||
DEPS=$(patsubst %,$(IDIR)/%,$(_DEPS))
|
||||
|
||||
_OBJ=$(NAME).o
|
||||
_OBJ=$(NAME).o lib.o
|
||||
OBJ=$(patsubst %,$(ODIR)/%,$(_OBJ))
|
||||
|
||||
|
||||
|
1
compile_flags.txt
Normal file
1
compile_flags.txt
Normal file
@ -0,0 +1 @@
|
||||
-Iinclude
|
4
include/lib.h
Normal file
4
include/lib.h
Normal file
@ -0,0 +1,4 @@
|
||||
#ifndef LIB_H
|
||||
#define LIB_H
|
||||
void die(const char *message);
|
||||
#endif
|
7
src/lib.c
Normal file
7
src/lib.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void die(const char *message) {
|
||||
perror(message);
|
||||
exit(1);
|
||||
}
|
20
src/main.c
20
src/main.c
@ -1,3 +1,21 @@
|
||||
int main(void) {
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 2) {
|
||||
printf("usage: catclone <FILE>\n");
|
||||
die("args");
|
||||
}
|
||||
|
||||
FILE *fp = fopen(argv[1], "r");
|
||||
|
||||
if (fp == NULL) {
|
||||
die("fopen");
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user