473,657 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::en d) 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 4387
"Someonekic ked" writes:
if you create a new file , open it and only hit enter then save. if you
use seekg(0,ios::en d) 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::en d) 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, !
"Someonekic ked" <so***********@ comcast.net> wrote in message
news:56******** ************@co mcast.com...
if you create a new file , open it and only hit enter then save. if you
use seekg(0,ios::en d) 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
2927
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
22610
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 line by line, using "Line Input #myValue, myLine" to do so. My problem is that there are, occasionally, unusual Unicode characters
0
3116
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) into the mysql command line client running in a terminal window (konsole). MySQL server is version 4.0.12 running on a remote Linux server that I have connected to with ssh. When I paste polish characters into the command line client using a...
10
2983
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 (basically from everywhere) store it and properly serve it back to users, . . .? . Can you point me to info on this? I would preferably use Java/JDBC drivers.
28
9568
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
1859
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 (always going to be 2) and store them as characters. But I can't seem to get it to work because it is a pointer to a vector of characters. However, if I only run with integer arguements and use codeSnippet2 it works fine and they convert nicely to...
2
3036
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 <xsl:text> </xsl:text> to output a carriage return and line feed but they get stripped at some point. I'm passing a StringWriter to the XslTransform.Transform method. Anyway to get this to actually output the tab and carriage and line feed characters?
35
11418
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", "r+"); fseek(file, -2, SEEK_END); fscanf(file, "%d", &c); this works fine if the integer is only a single character. When I get into larger numbers though (e.g. 502) it only reads in the 2. Is there
21
5123
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 ? And even "\r" on Macintosh ? How to I get the end of line marker of the current platform ?
0
8411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6176
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.