I don't know why while loop can't
stop. It can't compare c with Delim neither stop by reaching
eof.
wchar_t* Getline(const
wchar_t* Filename, const wchar_t Delim){
FILE* f =
_wfopen(Filename, L"r, ccs=UTF-8");
wchar_t* info =
NULL;
wchar_t* temp = NULL;
int count = 1;
int i =
0;
wchar_t c;
c =
fgetwc(f);
while (c != Delim ||
!feof(f))
{
count++;
temp = (wchar_t*)realloc(info,
count * sizeof(wchar_t));
if (temp)
{
info =
temp;
info[i] = c;
i++;
}
else
{
free(info);
wprintf(L"Failed to read\n");
}
c =
fgetwc(f);
}
info[i] =
'\0';
fclose(f);
return
info;
}
After
reading all character in file. It seem not to stop. Even c are the same with Delim. And
!feof(f) hasn't worked too. I have try c != WEOF but fail
too
I thought that the problem is in the file
that I read but not. I have change another file but the same
problem.
Thanks for helping me!
No comments:
Post a Comment