|
I have tried this:
int nRespond = _open(device, _O_WRONLY | _O_CREAT);
UINT e = ::GetLastError();
with the same result (error 5). Strange ....
|
|
|
|
|
I also tried this:
#include <io.h>
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
_open("D:", 0x02 | 0x04);
UINT e = ::GetLastError();
cout << e;
}
from cmd line as administrator rights … the same result: 5 (access is denied).
|
|
|
|
|
Big Errors
You can't open "D:" that isn't a file ... its not linux you don't mount drives
Try
int nRespond = _open("D:\\somefilename.txt", _O_WRONLY | _O_CREAT);
UINT e = ::GetLastError();
I am sure it will open
In vino veritas
|
|
|
|
|
Agree. Is there any windows methods to open a disk and get the handle ? Because this nResponse it is used further as a handle ...
|
|
|
|
|
|
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 ...
|
|
|
|
|
How are you going to use the handle returned from _open ?
|
|
|
|
|
Windows has GetLastError you notice CreateFile Simply returns invalid handle for an error if you get that then you call GetLastError
GetLastError function (errhandlingapi.h) | Microsoft Docs[^]
That is the equivalent of your original int it's just a non zero number identifying the error, 0 always equals no error.
In vino veritas
|
|
|
|
|
Programming.. Backtracking.
I need help with backtracking question.
In an election, five parties won and got
A 20
B 14
C 30
D 16
E 40
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
|
|
|
|
|
This is a mathematical/logic question, which you need to solve first. Once you have done that then writing the code should be straightforward.
|
|
|
|
|
Washiko wrote: A + E + B is not valid
I don't see why not. Above the condition was stated that
Washiko wrote: a coalition of More than 60 must be negotiated
which means neither A+E nor A+B or B+E would be enough - all three are needed to get more than 60.
As for your program, if you don't know what backtracking means, look up recursion and backtracking. There's nothing difficult about coding these concepts in C. If you do know what it means, write a program and, if at any point you're stuck, show the code you're stuck with.
We don't write full programs for other people on request. If it's homework, we'd do you a disfavor by destroying a chance for you to learn. If it's work, you'd get paid, and you can't expect from others to do that work for you without payment. If it's a contest, it's part of the contest to find out how to write the program - if others do it for you it tells nothing about your skills, and it would be unfair to the other contestants.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Hi,
currently I am comparing the MeshCommander and the Intel Manageability Commander for configuring AMT Version 12.
With the MeshCommander I was able to configure AMT Version 12 for a TLS connection.
But I found no way to do the same with the Intel Manageability Commander.
1. Where are the setting in the Intel Manageability Commander for TLS configuration?
2. How can I configure TLS with Intel Manageability Commander?
Regards and thanks in advance for helpful answers
jo123
|
|
|
|
|
This has nothing to do with C/C++/MFC, or indeed software in general. Please find a more appropriate forum.
|
|
|
|
|
I am trying to convert a CString to const char*, and I have tried some versions:
CString sTemp("abcd");
const char* chTemp = (LPCSTR)(LPCTSTR)sTemp;
is one of them, but in chTemp I have only one letter from sTemp, not whole string ... why ?
|
|
|
|
|
|
I have converted the project to multi-byte character set (was unicode) and the behavior is the same ...
|
|
|
|
|
I have tried this also:
const char* chTemp = (const char*)sTemp.GetBuffer(0);
sTemp.ReleaseBuffer();
TRACE(">>>>>>>>>>>>>>>>>>>%s\n", chTemp);
the project is not multi-byte ... the same result, just one letter (first letter) from the string ...
|
|
|
|
|
_Flaviu wrote: the project is not multi-byte
Is it "not multi-byte" or "multi-byte"?
|
|
|
|
|
Sorry, is multi-byte .. .anyway, if the project is unicode or is multi-byte, is the same thing.
|
|
|
|
|
Try these tests:
CStringA ansiText("TestA");
LPCSTR ansi = (LPCSTR)ansiText;
TRACE("%s\n", ansi);
CString someText("Test");
ansi = (LPCSTR)someText;
TRACE("%s\n", ansi);
What is the result?
|
|
|
|
|
with the first try:
CStringA ansiText("TestA");
LPCSTR ansi = (LPCSTR)ansiText;
TRACE("%s\n", ansi);
the result is TestA
for the second try, I got an error:
1>d:\tempx\test\testdoc.cpp(53): error C2440: 'type cast' : cannot convert from 'CString' to 'LPCSTR'
at
CString someText("Test");
ansi = (LPCSTR)someText; TRACE("%s\n", ansi);
The project is unicode.
|
|
|
|
|
_Flaviu wrote: for the second try, I got an error:
1>d:\tempx\test\testdoc.cpp(53): error C2440: 'type cast' : cannot convert from 'CString' to 'LPCSTR'
at
CString someText("Test");
ansi = (LPCSTR)someText; TRACE("%s\n", ansi);
The project is unicode. |
Of course you get the error since the CString contains the wide char text!
Either change the build to be MBCS/ANSI or convert CString to wchar_t* (or use _T() macro).
|
|
|
|
|
"build to be MBCS/ANSI" you meant multi-byte project ?
|
|
|
|
|
Go to Project -> Properties -> General and make sure Character set is set to "Use Multi-Byte Charachter Set".
|
|
|
|
|
_Flaviu wrote:
TRACE(">>>>>>>>>>>>>>>>>>>%s\n", chTemp); What if you try:
TRACE(">>>>>>>>>>>>>>>>>>>%S\n", chTemp);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|