char *loadTextFile(const char *filename)
{
FILE *fileh;
char *text = 0;
long filelength;
if((fileh=fopen(filename,"rb"))== 0)
printf("loadTextFile() - could not open file");
else
{
fseek(fileh, 0, SEEK_END);
filelength = ftell(fileh);
rewind(fileh);
text=(char *) smartmalloc((int)filelength + 1);
fread(text,(int)filelength, 1, fileh);
fclose(fileh);
text[filelength]=0;
}
printf(text);
return(text);
}
This function only returns partial data of a txt file. It is also inconsistent...soemtimes gives me 100 characters of the file some times 20. I don't see anything wrong with it. Thought I might get another pair of eyes on it. Thanks.