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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing newline character '\n' 1

Status
Not open for further replies.

tdnash

Programmer
Aug 23, 2004
2
US
I am using Visual c++ .net to create a MS Word document.

I created the .doc in word, then did an octal dump on it so I could see, character by character, what the .doc file consisted of.

Now, I am attempting to re-create the .doc by writing a C++ prg that simply opens a file, and does a series of fprintf statements to write, character by character, the exact same data that was in the MS Word created document.

I see many \n symbols in the word document, I try and write these out with:
fprintf(fout,"\n");
and when I do an octal dump on my file, I see that statement wrote 2 charcters: \r \n
how do I write out the \n without the \r
that is the ultimate question....
Thanks,
Todd
 
You're opening your file in text mode, which performs automatic translation of single newlines into \r\n pairs.

Open the file in "wb" mode to prevent this translation from happening.

--
 
Salem - you hit this one out of the park! Right On the money! Thank You Very Much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top