From d94d279532c7933e3f3b785d8e72c487757c9efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Wed, 25 Mar 2020 06:12:47 -0300 Subject: Read command line argument into memory --- jet.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'jet.c') diff --git a/jet.c b/jet.c index d600ffc..4000b32 100644 --- a/jet.c +++ b/jet.c @@ -5,8 +5,17 @@ #include int main(int argc, char *argv[]) { + char *buffer = 0; if (argc > 1) { int file_descriptor = open(argv[1], O_RDWR); + + struct stat file_stat; + stat(argv[1], &file_stat); + size_t file_size = file_stat.st_size; + + buffer = malloc(file_size); + read(file_descriptor, buffer, file_size); + close(file_descriptor); } return 0; -- cgit v1.2.3