poniedziałek, 5 listopada 2018

Reading data from a file (C++)


I want to find out what happened at the given time in the system.
Windows stores error reports in the file - PFRO.


Functions for char and wchar_t types:

wchar_t* __fastcall TForm1::PFRO_Report() { wchar_t end='\0'; wchar_t *report; wchar_t *reply; wchar_t temp_buff[2048]; wchar_t *incident=L"3/18/2017 18:27:22 - PFRO Error:"; size_t byt_read_values; FILE *file; file=_wfopen(L"c:\Windows\PFRO.log",L"r+"); byt_read_values=fread(temp_buff,1,sizeof(temp_buff),file); fclose(file); temp_buff[byt_read_values]=end; report=wcsstr(temp_buff,incident); if(report==0) return 0; swscanf(report,incident,L"%s",reply); return reply; }

char* __fastcall TForm1::PFRO_Report() { char end='\0'; char *report; char *reply; char temp_buff[2048]; char *incident="3/18/2017 18:27:22 - PFRO Error:"; size_t byt_read_values; FILE *file; file=fopen("c:\Windows\PFRO.log","r"); byt_read_values=fread(temp_buff,1,sizeof(temp_buff),file); fclose(file); temp_buff[byt_read_values]=end; report=strstr(temp_buff,incident); if(report==0) return 0; sscanf(report,incident,L"%s",reply); return reply; }

Brak komentarzy:

Prześlij komentarz