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:
commit
63332c6221
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
fisualizer
|
||||
*.o
|
18
Makefile
Normal file
18
Makefile
Normal 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
33
fisualizer.c
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user