• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

what do i write to a text file to make notepad see a carriage return?

zsouthboy

Platinum Member
After I write a string to a file, i'd like to go to the next line for the next..

Isn't there a code (^M$ or something<- i tried that, btw, didn't work) that is carriage return?

EDIT: Whoa, that post was barely legible... i need some coffee for sure...

 
It depends on what language you are working in.

For C, as singh posted, it's \r\n, \r = carriage return, and \n = new line

For other languages, it's a little different. In VB you can use the constant vbCrlf, which is actually just Chr(10) & Chr(13) (if I remember right.. it might be 13 & 10... heh)

Plus there are other options for other languages...
 
heh.. of course its not \r\m, that would be too easy..

Lemme try explain better.

VC++.

I am taking a string, and writing it to a file (log.txt).
I want to put a carriage return after every time I write the string.
\r\n (which are C++ anyway) and ^M$ do not work..

suggestions?
 
I want the carriage return to appear in NotePad when I open it using NotePad... that's what i mean, what symbols does notepad actually use so i can write them to the file along with the strings?
 
okay... NOW \r\n works... but it puts a wierd character in..

&yacute;

/\
|
puts that on the next line.. hmm
 
Okay forget it... i'm going to create a blank .txt file, hit enter once, and find out what the hell is in it.... argh...
 
yes, that would be the easy way to do it.

but, i do things the hard way... lol..

i'm using the CFile class to do file io...



I figured out what the two characters are, and yes, they are 13 and 10 (0D and 0A accordingly)... now, figure out how to write hex to a file...
 
You don't need to write hex, hex and decimal are just different ways of representing the same value.

Using "\r\n" is no different from using (char)13 (char)10, afaik. If you are using C++ you might as well use its facilities to the fullest extent and just use endl. If you want to code c then just code c.
 
Back
Top