LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-30-2006, 07:40 PM   #1
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
c++ file IO without newline?


Okay, I'm almost certain that this is going to wind up being very simple, but for some reason I just can't think of it. I'm writing a c++ program using fstream to do file output. Every time I use the << operator to write to the file it tacks on a newline. What function/options do I need to use to eliminate the newline, so that after numerous writes, the program is still just one line? (Not intended to be human readable)
 
Old 12-30-2006, 07:54 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Are you using std::endl? That would explain it.
 
Old 12-30-2006, 08:07 PM   #3
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148

Original Poster
Blog Entries: 1

Rep: Reputation: 48
Ah, yep. Thanks much.
 
Old 12-31-2006, 03:24 PM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
<< inherently sends formatted output (like screen output) to the file. This passes the output through a locale first so that numbers leave as text, etc. If you don't intend to write text and you want to specify the exact bytes written (e.g. 1 is written as 0x01 and not "1") you should open with the std::ios::binary open mode and use the write() function with the fstream.
ta0kira
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apt-get dpkg error: files list file ... missing final newline PBSchmidt Debian 13 04-29-2023 05:55 PM
bash file test - newline is a directory? haxcess Linux - General 2 03-26-2006 11:34 AM
warning: no newline at end of file huno Programming 1 07-16-2004 09:39 AM
What is a newline? raptorsoft2000 Linux - Newbie 6 08-04-2003 10:05 PM
Warning: no newline at end of file acid_kewpie Programming 1 03-13-2002 02:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration