#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
typedef struct dictionary_entry
{
char *eng;
char *gr;
} term;
len = 0;
term *terms, *trm;
terms = (term*)malloc(0);
char temp1[50], temp2[50];
trm = (term*)malloc(0);
trm->eng = (char*)malloc(0);
trm->gr = (char*)malloc(0);
FILE *in = fopen("dictionary.txt", "r");
while(feof(in) == 0)
{
fscanf(in, "%s %s\n", temp1, temp2);
trm = (term*)realloc(trm, sizeof(term));
trm->gr = (char*)realloc(trm, sizeof(char) * strlen(temp1));
trm->eng = (char*)realloc(trm, sizeof(char) * strlen(temp2));
strcpy(trm->gr, temp1);
strcpy(trm->eng, temp2);
add(&terms, trm, &len);
}
free(trm->eng);
free(trm->gr);
free(trm);
fclose(in);
I was trying to read sets of words from my file (eg. word translation) to create a dictionary but as soon as I run the program it crashes. The debugger points me out to the realloc function and an arror message appears. The message is
[debug]Cannot find bounds of current function
and the problem seems to have something to do with the realloc function I'm using. Has anyone faced that problem and if so how can I solve it?
I am using Code::Blocks.