Note, i have to use pure C to do this. If i use an int array as an element of data storage to pass around functions, it all works. But if i use defined type i get an error "incompatible types in assignment". Problem is located in line "freq[var] = 0;" in following code:
ratetable *Collectrate(FILE *f) {
// int* freq = (int*) malloc(CHAR * sizeof(int));
ratetable* freq = (ratetable*) malloc(sizeof(CHAR * sizeof(int)));
int var;
for (var = 0; var < sizeof(freq); ++var) {
freq[var] = 0;
}
while (!feof(f)) {
freq[getc(f)]++;
}
//memcpy (freq2,freq,CHAR);
//free(freq);
return freq;
}
...
and
#define CHAR 256
typedef int ratetable[CHAR];
Tags: