Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2005

Tip: Looking for answers? Try searching our database.

FILE and line feed question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
james - 30 Jun 2005 15:17 GMT
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.
David Lowndes - 30 Jun 2005 17:25 GMT
>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
james - 01 Jul 2005 13:39 GMT
> >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
[quoted text clipped - 13 lines]
>
> 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
David Lowndes - 01 Jul 2005 17:48 GMT
>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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.