ok, now I need to get an actual pointer to the data in a vector, I have to pass this to a function that only accepts raw pointers.
This is a discussion on another vector question within the C++ Programming forums, part of the General Programming Boards category; ok, now I need to get an actual pointer to the data in a vector, I have to pass this ...
ok, now I need to get an actual pointer to the data in a vector, I have to pass this to a function that only accepts raw pointers.
Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.
so if I have -
I can just passCode:string Foo;
and that will point to the characters int eh string themselves?Code:MyFunction((LPVOID)&Foo);
Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.
Not even remotely...
Example:
Code:MyFunction((LPCVOID)Foo.c_str());
It seems that string (currently) doesn't really allow non-constant access to the internal buffer (it is not required to be contiguous). You can use a vector<char> instead of string.
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Pointers needn't be cast to void* in either C or C++ either.
Also there's no such thing as LPCVOID![]()
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
The only reason I put the cast was to assure that the OP was aware of the fact that std::string::c_str() is constant. Hence the LPCVOID.
There is no such thing as LPCVOID. I think it's just better to write const void*.
All those LP* defines/typedefs are evil anyway. They obfuscate code, makes it harder to read and more prone to errors.
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
Whether you like them or not, to say that they don't exist is absurd, and totally irrelevant to the thread, too.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
I said "LPCVOID" didn't exist. Unless you typedef that one yourself, it doesn't exist in any common windows header.
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
OK, you're right. Sorry.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
News to me. Never seen it before that I can remember.
But... I stand corrected.
Although, const void* is much easier to read and interpret rather than LPCVOID. I still stand fast to that.
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
And I grepped the wrong directory in my search.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
i am hearing such comments from someone who uses cryptic (to me, at least) #defines to make it even more difficult to understand template ridden code
but anyways such typedefs have advantages:
like:
Code:char* p, q r; // not all are pointers :( LPSTR p, q, r; // all are pointers :)