0

I was reading through WinHttp functions and tried executing an example code from MSDN. The first line of the code

LPSTR pszData = "WinHttpWriteData Example";

throws an error when I execute.

Error C2440 'initializing': cannot convert from 'const char [25]' to 'LPSTR'

I have already included the required header files and libraries of Windows and Strings.

#include <winhttp.h>
#include <windows.h> 
#include <string>
#include <strsafe.h>
#pragma comment(lib, "winhttp.lib")

I don't see any problem here. But why do I get an error?

When I searched for problems related to that program, people have executed the same program and it didn't throw an error for this statement or anything related to this.

James Z
  • 12,209
  • 10
  • 24
  • 44
Shrihari
  • 5
  • 4
  • use `PCSTR pszData = "WinHttpWriteData Example";` – RbMm Jun 23 '18 at 18:36
  • look for [Modifying String Literals](https://msdn.microsoft.com/en-us/library/69ze775t.aspx) and [`/Zc:strictStrings`](https://msdn.microsoft.com/en-us/library/dn449508.aspx) – RbMm Jun 23 '18 at 18:45

0 Answers0