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.
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.
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);
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.
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.
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
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
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 :)