If fseek() always clears EOF, is there a way for me to fread() from an
offset of a file and still be able to detect EOF?i.e. withouting using
fseek(). I also need to seek to an offset in the file
frequently(forw ards and backwards) and do fread() from that offset.
Or better still, could anyone let me know some good ways to achieve
what I need to do as above?Can I get hold of the file and being able
to read in without using fread()? Using memory addresses?
Thanks
Mar 24 '07
20 7533
Mark McIntyre wrote:
On Sun, 25 Mar 2007 22:52:04 -0700, in comp.lang.c , Keith Thompson
<ks***@mib.orgw rote:
>Chris Torek <no****@torek.n etwrites:
>>On very old MS-DOS systems, and systems that predated MS-DOS, *disk* files had a peculiar problem: they did not have a "size" associated with them. Instead of a "size", they had a "number of disk sectors".
I assume this kind of behavior is also why an implementation is allowed to append arbitrarily many null characters to the end of a binary file.
At least as likely it was due to VMS - all files are multiples of 512
bytes long, padded with nulls as required. Text files had ascii 26 to
mark the 'end' but the OS still considered a 12-byte file to be 512
bytes in size.
BTW isn't the file management family tree VMS->CPM->DOS?
Maybe so. CP/M used IBM's 8-inch floppy format as its basis. The IBM
unit record (sector) was 128 bytes and it was the smallest unit you
could read/write. Text files were terminated with ASCII 26 as above.
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein --- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: deko |
last post by:
I'm trying to control the size of a log file. When it gets more than 5k
oversize, I attempt to trim it thusly:
$fcap = intval(($dval * 0.0108))*1024; // what it should be
$fsize = filesize($file); // what it is
$oversize = $fsize - $fcap;
if ( $oversize > 5120 ) // 5k oversize
{
$fp = fopen($file,"r+");
|
by: Kenneth Brody |
last post by:
I recently ran into an "issue" related to text files and ftell/fseek,
and I'd like to know if it's a bug, or simply an annoying, but still
conforming, implementation.
The platform is Windows, where text files use CF+LF (0x0d, 0x0a) to
mark end-of-line. The file in question, however, was in Unix format,
with only LF (0x0a) at the end of each line.
First, does the above situation already invoke "implementation defined"
or "undefined"...
|
by: Maria Mela |
last post by:
Hello everyone...
I´ve a problem with my code, when i put this lines:
recsize = sizeof(p1);
fseek(fp,-recsize,SEEK_CUR); fwrite(&p1,sizeof(p1),1,fp);
getch();
The file was saved with correct values and with some windows informations
too!?
|
by: ericunfuk |
last post by:
A basic question:
When the documentation says "fseek() clears EOF indecator, does it
mean when you seek over EOF, EOF is no longer at the original position
and hence removed?Say, after I seek over the original EOF, when I
fread() from a previous position that I know is before the EOF then
fread will not be able to tell if it has encountered the original EOF?
Thank YOU!
|
by: ericunfuk |
last post by:
I have posted a few other posts before this one today, I still can't
solve my problem, I think I need to elaborate my problem now.
I'm trying to send a file using UDP, below is a segment of my sender
app, the sender and the receiver are both on the same machine and I
have an Internet emulation gateway running on the same machine as
well.
What I'm confused about is I can't detect when the end of the file I'm
sending has been reached,...
| |
by: ahmetbm |
last post by:
Hi;
I have a c program that uses mpi library to run on parallel arhitecture. First i coded serial program and it worked perfectly. But the parallel one did not run. I found the error but could not solve it.
The error is: the "fseek" and "fread" functions does not return the correct values.
fseek(wav_fp,40L,SEEK_SET);fread(&str,4,1,wav_fp);
this code must return "str" = "81913" but i get "-442495"
Thanks.
|
by: thomas.mertes |
last post by:
Hello
Recently I discovered some problem. I have some C code
which determines how many bytes are available in a
file. Later I use this information to malloc a buffer of
the correct size before I read the bytes.
Determining the number of bytes available in a
file is done in 5 steps:
1. Use tell(aFile) to get the current position.
|
by: kindrain |
last post by:
the code checks whether a.txt has exact the same lines, then write
different lines into b.txt
Here it is:
(before that ,you should creat a.txt)
----------------------
#include<stdio.h>
#include<string.h>
void main(){
FILE *fp,*ftemp;
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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,...
|
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...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |