Вызвано исключение по адресу 0x78F6F6E0 (ucrtbased.dll) в Parser2.exe: 0xC0000005: нарушение прав доступа при чтении по адресу 0x00000000.
main.cpp
#include "htmlgrab.h"
#include <urlmon.h>
#include <iostream>
#include <fstream>
int main()
{
try
{
char webAddress[256];
std::cout << "Enter webPage url - >" << std::endl;
std::cin >> webAddress;
HtmlGrabber htmlgrab;
char* sss = htmlgrab.GetHtmlText(webAddress);
std::cout << sss;
}
catch (const std::runtime_error& e)
{
std::cout << e.what() << std::endl;
return -1;
}
return 0;
}
htmlgrab.cpp
#include "htmlgrab.h"
HtmlGrabber::HtmlGrabber()
{
}
HtmlGrabber::~HtmlGrabber()
{
}
char* HtmlGrabber::GetHtmlText(char webAdders[256])
{
char FileName[70] = "result.html";
HRESULT hr = URLDownloadToFile(NULL, webAdders, FileName, 0, NULL);
if (hr == S_OK)
{
std::cout << "Success!\n";
std::ifstream fin(FileName);
char szBuff[2048];
while (fin.getline(szBuff, 2048))
{
std::cout << szBuff;
return szBuff;
}
}
else
{
throw std::runtime_error("Fail getting html");
}
return 0;
}
htmlgrab.h
#pragma once
#include <urlmon.h>
#include <iostream>
#include <fstream>
class HtmlGrabber
{
public:
HtmlGrabber();
~HtmlGrabber();
char* GetHtmlText(char webAdders[256]);
char webAddress;
};