wchar_t reading [closed]

怎甘沉沦 提交于 2019-12-25 02:43:12

问题


I have a mistake in the function for reading the file but I don't know what is wrong. all the symbols are read correctly when the symbol is beyond the ASCII table.

while ((c = fgetwc(file)) != WEOF) {
        if (c != L'\n') {
            if (i == buf_length) {
                buf_length += BUF;
                wchar_t *rebuf = realloc(tmp, buf_length * sizeof(wchar_t));
                if (rebuf == NULL) {
                    free(tmp);
                    tmp = NULL;
                    buf_length = 0;
                    return EALLOC;
                } else {
                    tmp = rebuf;
                }
            }
            tmp[i] = (wchar_t)c;
            i++;
        } else {
            list->size++;
            tmp[i] = L'\0';
            insertLast(list, tmp);
            i = 0;
        }

回答1:


Is _UNICODE defined? Also, check that you do not get an error (use ferror and feof) when you encounter WEOF as it could mean either.

http://msdn.microsoft.com/en-us/library/c7sskzc1%28v=vs.71%29.aspx



来源:https://stackoverflow.com/questions/8552296/wchar-t-reading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!