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

EOF character

Hi,

my text file contains many lines of text, some of the text contains EOF
character appended at the end of the text.

if I use:
while (fgets(buffstr, sizeof(buffstr), in_ptr)!=NULL), it will only reach
the first text that contains the EOF character, not to the end of the file.

How can run through the whole file to the end instead, in order to do some
own filtering process?

Thanks.

Nov 14 '05 #1
5 2137

The fgets() function is used for dealing with textfiles. What you want is the read() function (used together with open()), and you want to supply it with the "b" option for binary (see the manpage of read() for details).

Greetings, Chris

On Fri, 12 Nov 2004 09:54:04 +0800
"Magix" <ma***@asia.com> wrote:
Hi,

my text file contains many lines of text, some of the text contains EOF
character appended at the end of the text.

if I use:
while (fgets(buffstr, sizeof(buffstr), in_ptr)!=NULL), it will only reach
the first text that contains the EOF character, not to the end of the file.

How can run through the whole file to the end instead, in order to do some
own filtering process?

Thanks.


--
Christian Staudenmayer
University of Ulm, Germany
cs****@mathematik.uni-ulm.de

Nov 14 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Magix wrote:
Hi,

my text file contains many lines of text, some of the text contains EOF
character appended at the end of the text.

if I use:
while (fgets(buffstr, sizeof(buffstr), in_ptr)!=NULL), it will only reach
the first text that contains the EOF character, not to the end of the file.

How can run through the whole file to the end instead, in order to do some
own filtering process?
Open the file in binary mode

file = fopen("filename","rb");
Thanks.


- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBlBduagVFX4UWr64RAj+GAJ413pho75KMip4OcwnSJD bLa7DgAgCeN5Nw
FJRVpSVRuEX/crmcoZNw2Jk=
=Lg7Q
-----END PGP SIGNATURE-----
Nov 14 '05 #3
Oops, I've got that all wrong. My bad, it's 3 AM. :)

Greetings, Chris.
Nov 14 '05 #4

"Lew Pitcher" <lp******@sympatico.ca> wrote in message
news:vH********************@news20.bellglobal.com. ..
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Magix wrote:
Hi,

my text file contains many lines of text, some of the text contains EOF
character appended at the end of the text.

if I use:
while (fgets(buffstr, sizeof(buffstr), in_ptr)!=NULL), it will only reach
the first text that contains the EOF character, not to the end of the
file.

How can run through the whole file to the end instead, in order to do
some
own filtering process?


Open the file in binary mode

file = fopen("filename","rb");
Thanks.


- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBlBduagVFX4UWr64RAj+GAJ413pho75KMip4OcwnSJD bLa7DgAgCeN5Nw
FJRVpSVRuEX/crmcoZNw2Jk=
=Lg7Q
-----END PGP SIGNATURE-----


Thanks.
Nov 14 '05 #5
Christian Staudenmayer wrote:
The fgets() function is used for dealing with textfiles. What you
want is the read() function (used together with open()), and you want ^^^^ ^^^^
You misspelled both fread() and fopen() to supply it with the "b" option for binary (see the manpage of ^^^^^^^
You misspelled "your documentation" read() for details).

^^^^
Again, misspelling fread()
Nov 14 '05 #6

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

Similar topics

37
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be...
4
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the...
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
18
by: james | last post by:
Hi, I am loading a CSV file ( Comma Seperated Value) into a Richtext box. I have a routine that splits the data up when it hits the "," and then copies the results into a listbox. The data also...
9
by: simchajoy2000 | last post by:
Hi, I know what the ASCII Character Codes are for the 2nd and 3rd powers in VB.NET but I can't find the 6th power anywhere - does anyone know what it might be or if it even exists? Joy
15
by: wizardyhnr | last post by:
i want to try ANSI C99's unicode fuctions. so i write a test program. the function is simple, but i cannot compile it with dev c++ 4.9.9.2 under windows xp sp2, since the compiler always think that...
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
3
KevinADC
by: KevinADC | last post by:
Purpose The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class....
7
by: tempest | last post by:
Hi all. This is a rather long posting but I have some questions concerning the usage of character entities in XML documents and PCI security compliance. The company I work for is using a...
10
by: Paul W | last post by:
Hi all, I have an application that reads data in from a text file and stores it in a database. My problem is that there are some characters in the file that aren't being handled properly. For...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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
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.