Answer the question
In order to leave comments, you need to log in
Why does Visual Studio throw an error when compiling a program for a COM2 connection in C++?
Gives errors starting from the line HANDLE port; . Tell me what to fix:
#include <windows.h>;
#include "stdafx.h";
#include <iostream>;
using namespace std;
HANDLE port;
int main(int argc, _TCHAR* argv[])
{
int code;
cout << "DjkC start." << endl;
cout << "Print number code: ";
cin >> code;
if (code == 0) {
exit;
return 0;
}
if (code == 1) {
port = CreateFile("COM2", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (port == INVALID_HANDLE_VALUE) {
cout << "Error" << endl;
ExitProcess(1);
}
CloseHandle(port);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question