|
jackngill wrote:
Compilation failed due to following error(s). main.cpp:1:8: error: expected unqualified-id before ‘,’ token
wchar_t, _T() buffer[30] = {0};
^
main.cpp:1:15: error: expected initializer before ‘buffer’
wchar_t, _T() buffer[30] = {0};
^~~~~~
main.cpp:2:5: error: expected unqualified-id before ‘if’
if (::GetEnvironmentVariable(_T("SYSTEMDRIVE"), buffer, _countof(buffer)))
^~
For this:
wchar_t, _T() buffer[30] = {0};
if (::GetEnvironmentVariable(_T("SYSTEMDRIVE"), buffer, _countof(buffer)))
{
wchar_t, _T() path[MAX_PATH] = {0};
swprintf(path, _T("%s\windows\system32\calc.exe"), buffer);
TRACE(path);
SetSfcFileException(0, path, -1);
}
What the abracadabra you wrote?
Try
wchar_t buffer[30] = {0};
if (::GetEnvironmentVariable(L"SYSTEMDRIVE", buffer, 30))
{
wchar_t path[MAX_PATH] = {0};
swprintf(path, L"%s\windows\system32\calc.exe", buffer);
TRACE(path); SetSfcFileException(0, path, -1);
}
|
|
|
|
|
The only error now being reported back is this one by the way sorry for the gobble-de-gook code must have cut & paste wrong.
main.cpp:2:1: error: expected unqualified-id before ‘if’
if (::GetEnvironmentVariable(L"SYSTEMDRIVE", buffer, 30))
^~
"If" for some reason is proving a problem but only one error repoted though encouraging it is under the input tab on the compiler. Perhaps an if/else might work?
Best Regards,
David
modified 5-Sep-20 6:07am.
|
|
|
|
|
|
@ Victor
LOL! Nope I have been using google to try to find some form of explanation I have been trying to input code within the online compiler based on the search engines but although the search error codes are similair there examples do not work for me.
I think I am going to draw a line under this endevour as coding is clearly not for me & it is far reach from exchanging one item "C:\\" for "%SystemDrive%" for another in the hope it would work. However many thanks for your patience & help I am very grateful but I have decided to quit.
If you want to proceed and complete the code feel free to do so there maybe others who would benefit from it.
All the best Victor.
|
|
|
|
|
|
istream& operator>>(istream& cin, Vector<class T>& v)
{
cout << "input size" << endl;
int n ;
cin >> n;
cout << "intput vector" << endl;
for (int i = 0; i < n; i++)
{
T data;
cin >> data;
v.push_back(data);
}
return cin;
}
int main()
{
Vector <string>v(5);
cin>>v;
}
Getting error undefined type T data;
|
|
|
|
|
If your intention is to use std::vector , your problem is that it shouldn't be capitalized.
|
|
|
|
|
No, actually I am trying to build a custom vector class.
|
|
|
|
|
Then see Mircea's first solution below, but keep Vector capitalized.
|
|
|
|
|
Either you make your function a template:
template <typename T>
istream& operator>>(istream& cin, vector<class T>& v)
{
...
or you make it a specific function for vectors of strings:
istream& operator>>(istream& cin, vector<string>& v)
{
cout << "input size" << endl;
int n;
cin >> n;
cout << "intput vector" << endl;
for (int i = 0; i < n; i++)
{
string data;
cin >> data;
v.push_back (data);
}
return cin;
}
Either solution works.
(that's beside Greg's observation about capitalization.)
Mircea
|
|
|
|
|
|
When using already existing container types from the STL, just use the container type as template parameter. You can retrieve the element type with the internal type definition value_type like this:
template <class Container>
istream& operator>>(istream& my_istream, Container& v)
{
typedef typename Container::value_type T; ...
If you define your own container type, you can do it in the same way. You just have to make sure your container type does define value_type :
template <class Element>
class MyContainer {
public:
typedef Element value_type;
...
P.S.:
IIRC STL containers already do have overrides for operator>>. You could save yourself some effort by just overriding this operator for your base type:
template <class T>
istream& operator>>(istream& my_istream, T& value) {
... It should work just as well as the above solution.
P.P.S.:
As it turns out I was wrong. There are no default implementations of operator>> for containers.
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)
modified 1-Sep-20 12:11pm.
|
|
|
|
|
char a, b;
printf ("write two letters")
scanf("%c %c", &a,&b);
printf("%c %c",b, a );
return 0;
when I run the program and press x and y for example y disappears when I use printf
|
|
|
|
|
Could you copy and paste the code you're running? What you've posted won't compile.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Works fine after fixing the missing semi-colon.
|
|
|
|
|
Is that a space in the middle of your scanf format? If so, you need to type “x(space)y”.
Mircea
|
|
|
|
|
No, it works with or without the space.
|
|
|
|
|
Apart from the missing semi-colon at the end of the first printf statement, the code works fine.
|
|
|
|
|
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
|
|
|
|
|
Is there a specific issue? Could you post the code that you have tried?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Exactly what help do you need?
|
|
|
|
|
vafoqome wrote: A + E + B is not valid
Is that an additional restriction? This combo looks perfectly valid to me - it fullfils all the requirements.
As for backtracking, there's plenty of literature on that topic, and I'm sure lots of example codes as well.
Other than that, what is your question?
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)
|
|
|
|
|
vafoqome wrote: I need help with backtracking question.
Helping you is not solving the problem for you.
Show your work so far, and explain problem you encounter.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Hi.
Please help me.
First of all, I hope you understand that the sentence structure can be strange as I ask questions using a translator machine.
I am developing a mini filter driver that prohibits reading from drivers other than the local disk drive.
However, IRP_MJ_CREATE does so much.
For example, it is also used to create volume drives the moment I open Explorer.
I don't want IRP_MJ_CREATE to be used when volume drives are created the moment I open Explorer.
Currently, I have registered IRP_MJ_CREATE in preOperation.
In the preOperation function, if it is not a local disk drive,
Data->IoStatus.Status = STATUS_NO_SUCH_PRIVILEGE;
Data->IoStatus.Information = 0;
It has been coded to make this work work.
Then, the moment I turned on Explorer, even the volume drives other than the local disk drive became inaccessible.
The first thing I want is that when Explorer opens, the volume drive will show up as accessible just like a local drive.
Second, I want files to be prevented from being read (prohibited to execute) when entering the volume drive.
I think the words are simple, but I think you need advanced technology. Still, I would be grateful for any help.
Thank you.
|
|
|
|
|
Hi,
I have not worked with mini filter drivers for about six years. But here are some things I think may help:
1.) In your PFLT_PRE_OPERATION_CALLBACK[^] callback you should probably allow anything originating from kernelmode to pass through. You can do this with ExGetPreviousMode[^] which will return KernelMode for file operations originating from the Windows kernel.
2.) After you have allowed kernelmode file operations to pass unmolested you can get the process ID of the usermode process performing the i/o with PsGetCurrentProcessId[^] and filter out whatever you want to pass through.
I don't normally send anyone away from codeproject.com but since I know that at least half of the Devices and Drivers team are active on the site I will defer you over to the NTFSD forum over at community.osr.com[^] where they are working with minifilters on a daily basis.
Best Wishes,
-David Delaune
|
|
|
|