Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8738605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:45:59+00:00 2026-06-13T10:45:59+00:00

Why next code give an error? Look code and pictures. How to fix it

  • 0

Why next code give an error? Look code and pictures. How to fix it
enter image description here

wchar_t *GetLine(wchar_t *fileName=L"indexing.xml", wchar_t endSymbol = '\n')
{
    FILE *file = NULL;
    int sz;
    _wfopen_s(&file, fileName, L"r");
    std::wifstream fs (file);
    int size;
    wchar_t wchr[1];
    size = 0;
    do
    {
        sz = fread(&wchr,sizeof(wchar_t),1,file);
        if(!sz)
        {
            break;
        }
        tempGetLine[size] = wchr[0];
        size++;
    }while(wchr[0] != endSymbol);
    tempGetLine[size] = '\0';
    position += (size);
    fs.close();
    return tempGetLine;
}

but this work correct

wchar_t *GetLine(wchar_t *fileName=L"indexing.xml", wchar_t endSymbol = '\n')
{
    hReadFile = CreateFileW(L"indexing.xml",GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ |FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    SetFilePointer(hReadFile,sizeof(wchar_t) * position, NULL, FILE_BEGIN);
    int size;
    wchar_t wchr[1];
    DWORD dw;
    size = 0;
    do
    {
        ReadFile(hReadFile, wchr, sizeof(wchar_t), &dw, NULL);
        if(!dw)
        {
            break;
        }
        tempGetLine[size] = wchr[0];
        size++;
    }while(wchr[0] != endSymbol);
    tempGetLine[size] = '\0';
    position += (size);
    return tempGetLine;
}

enter image description here
Full code

#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <Windows.h>
int position = 0;
wchar_t tempGetLine[500];
wchar_t *GetLine(wchar_t *fileName=L"indexing.xml", wchar_t endSymbol = '\n')
{
    FILE *file = NULL;
    int sz;
    _wfopen_s(&file, L"C:\\indexing.xml", L"r");
    std::wifstream fs (file);
    int x = GetLastError();
    fseek(file,sizeof(wchar_t) * position,SEEK_SET);
    int size;
    wchar_t wchr[1];
    size = 0;
    do
    {
        sz = fread(&wchr,sizeof(wchar_t),1,file);
        if(!sz)
        {
            break;
        }
        if(wchr[0] >= L'А')continue;            //Only for console application
        tempGetLine[size] = wchr[0];
        size++;
    }while(wchr[0] != endSymbol);
    tempGetLine[size] = '\0';
    position += (size);
    fs.close();
    return tempGetLine;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:46:00+00:00Added an answer on June 13, 2026 at 10:46 am

    Your file has failed to open for some reason and file is NULL. Always check that files open.

    Also got to wonder what you think you are doing with fs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why does the following code give a 80004005 error when run? I'm trying to
**the next code should parse a data from a webService to textView; Problem :
The next code runs normally in SQLSERVER but when i change the web.config to
I have next code, <form id=form1 runat=server> <asp:Label runat=server ID=Label1 EnableViewState=false /> <asp:CheckBox runat=server
Someone explain why the next code returns a pointer inside ntdll.dll? GetProcAddress(LoadLibraryA(kernel32.dll), EncodePointer); GetProcAddress(LoadLibraryA(kernel32.dll),
i have written the next code: public void delete(MyType instance) { List<MyType> myList =
Given the next code example, I'm unable to free the parameter const char* expression
I have the next code: class Printer{ Activity activity; public Printer (Activity activity) {
I have the next code : public class AddPrinter extends ListActivity { @Override public
I have next code: int main() { OwnSelect(23, FD_READ | FD_WRITE); // <---- Several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.