fseek Questions
4
Solved
If I have a text file with the following content opened as binary
1234567890
a call like this:
fseek(fp, 5L, SEEK_SET);
give me 6 when I call (char)fgetc(fp) because I offset 5 byte from byt...
2
Solved
while (fread(&product, sizeof(Product), 1, file) == 1) {
product.price *= 2.0;
fseek(file, -sizeof(Product), SEEK_CUR);
fwrite(&product, sizeof(Product), 1, file);
fseek(file, 0, SEEK_C...
Leeland asked 14/5, 2023 at 3:58
1
Solved
C2x, 7.21.9.2 The fseek function:
Synopsis
#include <stdio.h>
int fseek(FILE *stream, long int offset, int whence);
Why does fseek have long int offset instead of long long int offset?
It ...
Chalcography asked 7/2, 2022 at 15:4
10
Solved
How do I read a file backwards line by line using fseek?
code can be helpful. must be cross platform and pure php.
many thanks in advance
regards
Jera
2
I am trying to build Android L for 64-bit architecture.
My code goes like:
#if (HAS_LARGE_FILE_SUPPORT)
#define _FILE_OFFSET_BITS 64 //Defined in header file
/*Some File operations*/
#if HAS_LA...
Weitzel asked 28/9, 2015 at 15:3
2
I have a few text files whose sizes range between 5 gigs and 50 gigs. I am using Python to read them. I have specific anchors in terms of byte offsets, to which I can seek and read the correspondin...
4
Solved
I'm reading data from a file to memory that is opened with:
FILE *f = fopen(path, "rb");
Before I start copying bytes from the file I seek to a start position using:
/**
* Goes to the given ...
2
Solved
2
Solved
I need some data from a specific byte in range in a binary file.
(concatenated jpegs, don't ask...)
So I have a offset and length data from an external API.
(I would guess that those are byte posi...
4
Solved
Here is my code:
<?php
$url="http://www.sina.com.cn";
$handle = @fopen($url, "r");
$len=get_headers($url,true);
print_r($len);
echo $len['Content-Length']."\n";
if ($handle) {
while (($b...
2
I have a bad performance running fseek(..) in a very big file.
Every time a call fseek function, I need to move the file pointer position backward 100 bytes:
fseek(fp, -100, SEEK_CUR);
before, ...
2
Solved
I have started learning C (via Youtube and K&R) some time ago and I am trying to write some programs as practice.
Currently I want to create a program that reads words from a file and compares ...
1
I have old 32-bit C/C++ program on FreeBSD, which is used remotely by hundreds of users, and author of which will not fix it. It was written in unsafe way, all file offset are stored internally as ...
Trierarch asked 29/6, 2014 at 1:18
1
Solved
The C spec has an interesting footnote (#268 C11dr §7.21.3 9)
"Setting the file position indicator to end-of-file, as with fseek(file, 0, SEEK_END), has undefined behavior for a binary stream (b...
2
Solved
I'm trying to append the contents of a file myfile.txt to the end of a second file myfile2.txt in c. I can copy the contents, but I can't find a way to append. Here's my code:
FILE *pFile;
FILE *p...
2
Solved
I have noticed two methods to return to the beginning of a file
FILE *fp = fopen("test.bin", "r")
fseek(fp, 0, SEEK_END);
rewind(fp);
and
FILE *fp = fopen("test.bin", "r")
fseek(fp, 0, SEEK_EN...
2
Solved
offset=ftell(ptr)-sizeof(student1);
fseek(ptr,offset,SEEK_SET);
fwrite(&student1,sizeof(student1),1,ptr);
This C code means move the pointer from the current position ftell(ptr) to start of t...
5
Solved
I've read posts that show how to use fseek and ftell to determine the size of a file.
FILE *fp;
long file_size;
char *buffer;
fp = fopen("foo.bin", "r");
if (NULL == fp) {
/* Handle Error */
}
...
1
Solved
3
Solved
4
Solved
Similar to: How to read only 5 last line of the text file in PHP?
I have a large log file and I want to be able to show 100 lines from position X in the file.
I need to use fseek rather than file(...
Janettejaneva asked 23/5, 2012 at 0:47
1
Solved
FILE* f = fopen("rajat", "w");
fputs("sometext", f);
fseek(f, 6, SEEK_SET);
fputs("is a", f);
fclose(f);
Successfully returns: "someteis a"
But
FILE* f = fopen("rajat", "a");
fputs("sometext", ...
3
Solved
I am wondering if this is the best way to go about solving my problem.
I know the values for particular offsets of a binary file where the information I want is held...What I want to do is jump t...
4
Solved
In C or C++, the following can be used to return a file size:
const unsigned long long at_beg = (unsigned long long) ftell(filePtr);
fseek(filePtr, 0, SEEK_END);
const unsigned long long at_end = ...
2
Solved
Since fseek() does not work on pipes what methods exist for simulating seeking forward? The naive approach is to use fread() and throw away the contents read into the memory buffer. For huge seeks ...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.