From 63332c6221cb7e0dfccf8c4d053544d5c0ea0869 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Thu, 19 Oct 2023 22:57:01 +0200 Subject: [PATCH] Brand new world! This is a project that aim to visualize any kind of file by seeing how frequent are association of two characters in a file. This idea comes from conti & corte (I have to find the source then I'll put it in the readme...) --- .gitignore | 2 ++ Makefile | 18 ++++++++++++++++++ fisualizer.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 fisualizer.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c60f6c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +fisualizer +*.o diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f31360a --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +.PHONY: clean, mrproper +CC = gcc +CFLAGS = -g -Wall -Wextra -pedantic + +all: fisualizer + +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +fisualizer: fisualizer.o + $(CC) $(CFLAGS) -o $@ $+ + +clean: + rm -f *.o core.* + +mrproper: clean + rm -f fisualizer + diff --git a/fisualizer.c b/fisualizer.c new file mode 100644 index 0000000..4f34850 --- /dev/null +++ b/fisualizer.c @@ -0,0 +1,33 @@ +#include +#include + +FILE *fd; +size_t file_sz; +char* file_cnt; + +int main(int argc, char *argv[]) +{ + while(argc--){ + + const char* filename = *argv++; + fd = fopen(filename, "r"); + if(fd == NULL){ + fprintf(stderr, "couldn't open this file: %s\n", filename); + continue; + } + + // get file size + fseek(fd, 0, SEEK_END); + file_sz = ftell(fd); + rewind(fd); + + file_cnt = malloc(sizeof(char)*file_sz); + fread(file_cnt, sizeof(char), file_sz, fd); + + printf("%s\n", file_cnt); + + free(file_cnt); + fclose(fd); + } + return 0; +}