Oops! you are right. Correction to the title. It should read as problem with 
strings ...
Anyway I am unable to declare it as str[]="Hello" due to other complications. 
If you have a look at the file VCPlus2008Code.cpp that I have uploaded, you 
will see what I mean. The parser splits the passed string (passed as 
pointer)into three substring pointers. I am trying to write a RightTrim to 
strip the substring. So far the dll builds ok. But when I run it, crashes when 
it tries to access the substring after it has been passed into the RightTrim. 
So I tried to do a string copy of the substring and then passed the copy to the 
RightTrim function. That way I thought I leave the original substring intact. 
Still the dll crashes. I am sure eventually i will be able to crack it. In the 
mean time this might pose an interesting challenge to other keen VC++ 
experts....

Thanks for your helpful suggestions

TFE
http://totallyfreeenergy.zxq.net

--- In [email protected], "johnmatthews2000" <jm5...@...> wrote:
>
> --- In [email protected], "totallyfreeenergy" <totallyfreeenergy@> wrote:
> >
> > char* pChar;
> >  pChar = "Hello";
> > 
> > pChar is considered a constant and placed in read-only
> > section of memory.
> 
> Strictly speaking it's the string which is placed in read-only memory; the 
> pointer variable pChar is in 'ordinary' memory, so it can be modified to 
> point somewhere else.
> 
> The simple solution is to use:
> 
>   char str[] = "Hello";
> 
> This declares a variable which is an array of characters, instead of a 
> pointer variable. And str hasn't been declared const, so it may be modified.
>


Reply via email to