Archived

This topic is now archived and is closed to further replies.

Telamon

Carriage return(\n) in CStrings

Recommended Posts

Telamon    157
I''m using MFC and have a CString attached to an Edit Box. I have set the multiline property to true and would like to show multiple lines of text now. Of course, \n doesn''t work with CStrings like it does in C Strings. I checked all the help files that came with VC++ and couldn''t find the answer. Microsoft bastards. Do I need to make a C String and then transcribe it into a CString to get carriage returns?! I''m sure I''m missing something here. ----------------------------- Let be be finale of seem, seems to me.

Share this post


Link to post
Share on other sites
Gaiiden    5710
try using endl. I dunno if it''ll work with CString & MFC but this is how you use it with regular C++:

cout << "hello" << endl;

==============================
\\// live long and prosper; \||/ die short and rot.
==============================

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
I''m quite certain that CStrings can hold newlines-- I use them all the time to store blocks of text. In fact, I think CStrings are one of the few things that MFC got right-- they are a pretty efficient construct.

So I bet the problem has to do with the edit control''s handling (mangling) of the string. If you post some code I''ll take a look.

Share this post


Link to post
Share on other sites
gmcbay    130
I''m just posting to second Erik''s suggestion. ''\n'' isn''t a universal newline.

Under Windows based systems, a full newline is traditionally ''\r\n''. ''\n'' is, however, a full newline under UNIX (and some other) systems.

Share this post


Link to post
Share on other sites
Telamon    157
Yep! \r\n did the trick. Thanks again everybody! This is a great place to get help for these quirky kind of questions :-)

-----------------------------
Let be be finale of seem, seems to me.

Share this post


Link to post
Share on other sites