Confidence that I have solved all strange errors here, I come back with some issue generated by a legacy C code for linux, code that I intend to use it in a MFC app in windows OS.
Ok. I have a simple code:
int nRespond = _open(device, 020);
UINT err = ::GetLastError();
where devide is const char* and has value C (or D:, or E: )
The nRespond is -1 and err has value 5, which is mean Access is denied. What could be the problem here ? I ran the test app as administrator mode (ran from VS2017 as admin mode).
The problem appears to be that you are expecting Linux code to work on Windows. The _open function opens a file - on unix systems you can open directories and devices as files, but not on Windows.
If you're lucky the code is actually expecting a normal file and you just passed in a device letter by mistake. Otherwise you will have to port the code, replacing the Linux system functions with code that does the same thing on Windows.
You cannot run Linux code on Windows without adjusting it for the differences. Windows does not let you address raw devices in the same way that Linux does. And in fact doing so is very dangerous as you could destroy your entire system.
Good idea. I have used CreateFileA, and I get rid of that "access denied". But there a thing that I had afraid: the original code, with _open returned int, and CreateFileA return HANDLE ... casting HANDLE to int is OK ? I guess not ...
I need help with backtracking question.
In an election, five parties won and got
In order to rule, a coalition of More than 60 must be negotiated. But we have restrictions:
A does not sit with D
C does not sit with E
A B C D E
A. 1 1 1 0. 1
B. 1 1. 1 1. 1
C. 1 1. 1 1. 0
D 0 1. 1 1. 1
E. 1. 1. 0. 1. 1
The function should return the number of possible coalitions.. Which is 3.
As soon as the coalition is formed, no need to add more parties.
A + E + B is not valid
Last Visit: 31-Dec-99 18:00 Last Update: 20-Apr-21 19:42