Carriage return(\n) in CStrings
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.
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.
==============================
cout << "hello" << endl;
==============================
\\// live long and prosper; \||/ die short and rot.
==============================
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.
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.
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.
Under Windows based systems, a full newline is traditionally ''\r\n''. ''\n'' is, however, a full newline under UNIX (and some other) systems.
I had that same exact problem with a console mode game I''m working on. And yes, \n\r was how I had to fix it.
shut up
CAN I GET A WOO WOO!
shut up
CAN I GET A WOO WOO!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement