473,395 Members | 1,956 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,395 software developers and data experts.

FILE and line feed question

I'm using "FILE" function to write an array in a file and in this way I see
that when is present a line feed (10) the function automatically insert a
carriage return(13). This cause an error when i try to read the file. I would
like to know why this carriage return is inserted and if is possible to
prevent this. Another question about "FILE" function is that when I open and
read this file the function read only a little number of bytes and stop
itself like it meet an EOF. That isn't an EOF but the Exadecimal 1A byte.
Crazy this "file" :-). I never had similar experience with "FILE". It has
worked alway right. At this moment I'm using CFile and it work fine but I'm
curios to know what happen.

Thank you.
Nov 17 '05 #1
5 1540
>I'm using "FILE" function to write an array in a file and in this way I see
that when is present a line feed (10) the function automatically insert a
carriage return(13). This cause an error when i try to read the file. I would
like to know why this carriage return is inserted and if is possible to
prevent this.
When you open the file to write to it, ensure you open it in binary
mode rather than text mode (which translates /n to /r/n)
Another question about "FILE" function is that when I open and
read this file the function read only a little number of bytes and stop
itself like it meet an EOF. That isn't an EOF but the Exadecimal 1A byte.


0X1A is the EOF character - again it sounds like you're opening the
file in text mode.

Dave
Nov 17 '05 #2


"David Lowndes" wrote:
I'm using "FILE" function to write an array in a file and in this way I see
that when is present a line feed (10) the function automatically insert a
carriage return(13). This cause an error when i try to read the file. I would
like to know why this carriage return is inserted and if is possible to
prevent this.


When you open the file to write to it, ensure you open it in binary
mode rather than text mode (which translates /n to /r/n)
Another question about "FILE" function is that when I open and
read this file the function read only a little number of bytes and stop
itself like it meet an EOF. That isn't an EOF but the Exadecimal 1A byte.


0X1A is the EOF character - again it sounds like you're opening the
file in text mode.

Dave


I open the file with "a+" parameter to write and "r" parameter to read.
I've tried to open the file as binary but it return an error. In anyway I'll
try that again.
Can you tell me why if I read the file with "FILE*" procedure the EOF is
recognised with 0X1A and if I read the file with "CFile" procedure the EOF is
at the real end of file?

Thank you
Nov 17 '05 #3


"David Lowndes" wrote:
I'm using "FILE" function to write an array in a file and in this way I see
that when is present a line feed (10) the function automatically insert a
carriage return(13). This cause an error when i try to read the file. I would
like to know why this carriage return is inserted and if is possible to
prevent this.


When you open the file to write to it, ensure you open it in binary
mode rather than text mode (which translates /n to /r/n)
Another question about "FILE" function is that when I open and
read this file the function read only a little number of bytes and stop
itself like it meet an EOF. That isn't an EOF but the Exadecimal 1A byte.


0X1A is the EOF character - again it sounds like you're opening the
file in text mode.

Dave


I open the file with "a+" parameter to write and "r" parameter to read.
I've tried to open the file as binary but it return an error. In anyway I'll
try that again.
Can you tell me why if I read the file with "FILE*" procedure the EOF is
recognised with 0X1A and if I read the file with "CFile" procedure the EOF is
at the real end of file?

Thank you
Nov 17 '05 #4
>I open the file with "a+" parameter to write and "r" parameter to read.
I've tried to open the file as binary but it return an error.
I don't see why opening the file as binary should cause an error.
Can you tell me why if I read the file with "FILE*" procedure the EOF is
recognised with 0X1A and if I read the file with "CFile" procedure the EOF is
at the real end of file?


Probably because one is in text mode and the other isn't?

Dave
Nov 17 '05 #5
>I open the file with "a+" parameter to write and "r" parameter to read.
I've tried to open the file as binary but it return an error.
I don't see why opening the file as binary should cause an error.
Can you tell me why if I read the file with "FILE*" procedure the EOF is
recognised with 0X1A and if I read the file with "CFile" procedure the EOF is
at the real end of file?


Probably because one is in text mode and the other isn't?

Dave
Nov 17 '05 #6

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

Similar topics

7
by: Stewart Midwinter | last post by:
I want to parse a file with ElementTree. My file has the following format: <!-- file population.xml --> <?xml version='1.0' encoding='utf-8'?> <population> <person><name="joe" sex="male"...
1
by: james | last post by:
I'm using "FILE" function to write an array in a file and in this way I see that when is present a line feed (10) the function automatically insert a carriage return(13). This cause an error when i...
2
by: Brad Sanders | last post by:
Hello All, Thanks to Richard's answer to my last post I understand now what I have to do, but.. How do I put a Line Feed or a Form Feed into a text file? Looking throught the .net help it...
5
by: Neil Robbins | last post by:
I have a text file that stores a number of records that I need to access in a vb.net application. Each of the fields that make up a record are of a fixed number of bytes. So for instance there is...
4
by: Claire DURAND | last post by:
Hi, I try to open a distant (not local) XML file in PHP to read an RSS feed. I can open an HTML page and read it with the file() function. But as soon as I try with a RSS feed instead of...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
1
by: rengaraj | last post by:
Dear Experts, I am new to XML I want to create an Interview Questions Bank (Intra Net) for our institution. I preferred to store the Question & Answer in xml sheet. But if i vew the xml in...
5
by: Luis Zarrabeitia | last post by:
I need to parse a file, text file. The format is something like that: TYPE1 metadata data line 1 data line 2 .... data line N TYPE2 metadata data line 1 ....
2
by: Felipe De Bene | last post by:
I'm having problems parsing an HTML file with the following syntax : <TABLE cellspacing=0 cellpadding=0 ALIGN=CENTER BORDER=1 width='100%'> <TH BGCOLOR='#c0c0c0' Width='3%'>User ID</TH> <TH...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.