2021-03-15 20:04:23 +00:00
|
|
|
#include <stdio.h>
|
2021-03-19 16:56:57 +00:00
|
|
|
#include <malloc.h>
|
2021-03-15 20:04:23 +00:00
|
|
|
|
|
|
|
void print_array(int *array, int length) {
|
2021-03-19 16:56:57 +00:00
|
|
|
if (length == 0) {
|
|
|
|
printf("\n");
|
|
|
|
return;
|
|
|
|
}
|
2021-03-15 20:04:23 +00:00
|
|
|
|
|
|
|
printf("|");
|
|
|
|
|
|
|
|
for (int i = 0; i < length; ++i) {
|
|
|
|
printf("%d|", array[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
2021-03-19 16:56:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
char *read_file(char *filepath, int *len) {
|
|
|
|
FILE *f = fopen(filepath, "r");
|
|
|
|
|
|
|
|
fseek(f, 0, SEEK_END);
|
|
|
|
*len = ftell(f);
|
|
|
|
fseek(f, 0, SEEK_SET);
|
|
|
|
|
|
|
|
char *content = (char *) malloc(sizeof(char) * (*len + 1));
|
|
|
|
fread(content, 1, *len, f);
|
|
|
|
content[*len] = '\0';
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
return content;
|
|
|
|
}
|