Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CString problem

Status
Not open for further replies.

saidolsol

Programmer
May 31, 2001
10
0
0
ES
When i try to put some text from char* to CString, the newline character becomes a black vertical tab. So i can't see correctly the text i've read from a file and displayed in a text area. For some reasons i need to use char* instead of CString for buffering, and i need to use CString as text area variable.
any idea?
thanx.
gracias.
gràcies.
a10.
 
Try it, maybe will help.
CString xxxxx;
xxxxx.GetBuffer(xxxxx.GetBufferSetLength()+1);
John Fill
1c.bmp


ivfmd@mail.md
 
If you do the above you must remember to call ReleaseBuffer like this.

xxxxx.ReleaseBuffer()
 
hi,
i've done LPSTR pstr = str.GetBufferSetLength(/*length_of_text_file*/); and it doesn't need to ReleaseBuffer().
But the new line char problem is still there...

thanx.
gracias.
gràcies.
a10.
 
I once solved this problem (found the clue in MSDN).
You must add some extra control character for that, like \r.
Wait until tomorrow, I'll get the sample code from an archive...
 
VC will not tell you that you need the ReleaseBuffer but you do. What get buffer basically says is

Ok, give me your buffer allocated to this length and let me play around with it and when i am done I will give it back to you.

You give it back through the "release buffer"

As a guess, you must be writing the cstring to a text file in which case you WILL see the weird endline character. If you open it in word though, i am willing to bet that you wont see it. use "\r\n" to fix the problem.

Matt
 
it worked great!

thanks.
gracias.
gràcies.
a10.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top