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...)
This commit is contained in:
Debucquoy Anthony 2023-10-19 22:57:01 +02:00
commit 63332c6221
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
3 changed files with 53 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
fisualizer
*.o

18
Makefile Normal file
View File

@ -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

33
fisualizer.c Normal file
View File

@ -0,0 +1,33 @@
#include <stdlib.h>
#include <stdio.h>
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;
}