repl.it
@JosephCook/

compress

C

No description

fork
loading
Files
  • main.c
  • hh.c
  • test.j
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int **index = NULL;

void readTable(FILE *in){}

void addChr(int value){
	bool state = false;
	int len = sizeof(index[0])/sizeof(index), chr, amt;
	
	if(index == NULL){
		index[len][0]= value;
		index[len][1]= 2;
	}

	for(int i=0;i<len);i++){
		chr = index[i][0];
		amt = index[i][1];

		if(value == chr){
			index[i][1] = amt++;
			state = true;
		}
	}

	if(state != true){
		len++;
		index = realloc(index, len*(2*sizeof(int)));
		index[len][0] = value;
		index[len][1] = 1;
	}

}

int main(){
	char ch, *table;
	FILE *in, *out;

	if((in = fopen("test.j", "r+")) == NULL){
		return 1;
	}

	if((out = fopen("test.lvl", "r+")) == NULL){
		return 1;
	}

	index = malloc(2*sizeof(int));

	while((ch = fgetc(in)) != EOF){ addChr(ch); }
	rewind(out);
	table = malloc(sizeof(index)*sizeof(char));
	while(){
		
	}

	fclose(in);
	fclose(out);
	free(index);
}
Fetching token
?