quote:
Originally posted by optimism_
In both cases you will be getting a copy of the original. Presumable for c, patchou copies it into a new variable before passing it into the function or whatever. In VB it is defined as a copy
yes, plus makes a copy before calling the dll function. About VB, the ByVal in Strings is just a formalism... I bet you can change the decaration to ByVal bla as Long and you can cheat a bit with Windows APIs and modify the copy Plus makes.
quote:
Originally posted by optimism_
hence you CANNOT change the original text
not the original, of course, but yes the copy
quote:
Originally posted by optimism_
ps, choli
Actually is a const char*
this means the compiler wont let you change it unless you cast it to (char*) and if you do a cast, it will cause a runtime error, so no, you cannot change it in c at all
(so it doent have to be copied at all actually, cos theres no write access to it)
the const keyword is only used by the compiler to not let you change it (ie make something like sText[0]=mychar; ) however the internal (read assembler) implementation of it it's the same as if you don't put const. That's why I said you can remove the const keyword and all will work the same, just that now you'd be able to modify it.
about the cast, i don't think it'll do a runtime error... Anyway, you can also make
int dummy_ptr; //assume sizeof(int)=4
dummy_ptr=(int)sText; /*that's dodgy, i know, if you don't like it you can use void* instead of int too (dodgy too)*/
and then use dummy_ptr in an API like CopyMemory (or what ever it's called)....
Sumarizing, you can modify the string plus passes as parameter to the function (and plus won't use it once your function finishes)