473,413 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

new line character is considered as two characters

if you create a new file , open it and only hit enter then save. if you use
seekg(0,ios::end) and then tellg(), tellg() will return 2 (not 1); so new
line character is considered as two characters.

Is there a possible way so new line character can be considered (reading and
writing) as one character ? I need that in my program and the new line
character being two characters is messing up everything.
Jul 22 '05 #1
4 4371
"Someonekicked" writes:
if you create a new file , open it and only hit enter then save. if you
use seekg(0,ios::end) and then tellg(), tellg() will return 2 (not 1); so
new line character is considered as two characters.

Is there a possible way so new line character can be considered (reading
and writing) as one character ? I need that in my program and the new line
character being two characters is messing up everything.


In a non-Unix system, new line is usually silently stored as two characters,
CR and LF. When these characters are retrieved, they are *silently*
converted to one character again. In a binary file none of these
conversions occur. The word "binary" was a poor choice to describe this
phenomena.

I can't tell exactly what you are trying to do but investigate this area.

If you think of "binary" as meaning "strict ASCII" it may help get your arms
around this thing.
Jul 22 '05 #2
Someonekicked wrote:

if you create a new file , open it and only hit enter then save. if you use
seekg(0,ios::end) and then tellg(), tellg() will return 2 (not 1); so new
line character is considered as two characters.

Is there a possible way so new line character can be considered (reading and
writing) as one character ? I need that in my program and the new line
character being two characters is messing up everything.


You want to open the file in binary mode.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #3
thx a lot, now it works fine, !
"Someonekicked" <so***********@comcast.net> wrote in message
news:56********************@comcast.com...
if you create a new file , open it and only hit enter then save. if you
use seekg(0,ios::end) and then tellg(), tellg() will return 2 (not 1); so
new line character is considered as two characters.

Is there a possible way so new line character can be considered (reading
and writing) as one character ? I need that in my program and the new line
character being two characters is messing up everything.

Jul 22 '05 #4
i think you want to recheck your assumption. if you create a file, hit
return TWICE, and run your program, you get 3, not 4.

Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
6
by: Trevor Fairchild | last post by:
Hello, all. I am writing a program that parses an html report (generated by another program). I use the Open "C:\...." for Input As myValue method to open the html, and read through it...
0
by: Fraser Campbell | last post by:
Hi, We're trying enter polish language into mysql. My understanding is that polish language uses iso-8859-2 character set. I am cutting and pasting polish text from a web browser (Konqueror)...
10
by: Albretch | last post by:
.. Can you define the Character Set for particular tables instead of databases? . Which DBMSs would let you do that? . How do you store in a DBMS i18n'ed users' from input, coming over the web...
28
by: Colin JN Breame | last post by:
Hi, Fairly new to C. What is the best way to read a line (\n terminated) from a file? Ive looked at fscanf but was not sure which format specifier to use. (%s perhaps). Thanks Colin
8
by: Dawn Minnis | last post by:
Hey guys If I have a program (see codeSnippet1) that I compile to be called test.o Then run it as test.o n n 2 3 4 I want the code to be able to strip out the two characters at the start...
2
by: Buddy Ackerman | last post by:
Apparently .NET strips these white space characters (MSXML doesn't) regardless of what the output method is set to. I'm using <xsl:text> </xsl:text> to output a tab character and...
35
by: RyanS09 | last post by:
Hello- I am trying to write a snippet which will open a text file with an integer on each line. I would like to read the last integer in the file. I am currently using: file = fopen("f.txt",...
21
by: Timothy Madden | last post by:
Hello The examples in the php cli chapter in the manual end a line with "\n". For example echo "Total {$total}.\n"; Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows systems ?...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.