Questions tagged [fseek]

fseek is a C function belonging to the ANSI C standard library, and included in stdio.h. Its purpose is to change the file position indicator for the specified file or stream.

fseek() is a C function belonging to the ANSI C standard library, and included in the file stdio.h. Its purpose is to change the file position indicator for the specified file or stream. Because fseek uses 32 bit values on many platforms it has a limitation of maximum 2 gigabyte seeks. fseeko64 would be used for larger offsets.

See also

419 questions
-2
votes
1 answer

SEEK_END with WHENCE on binary stream

I'm confused by this statement, from C Programming: A Modern Approach, 2nd Edition on Page 446, For binary streams, fseek isn't required to support calls in which whence is SEEK_END Why is that? That seems like weird stipulation.
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
-2
votes
1 answer

Issue in reading specific portion of File

I am trying to extract and print a specific portion of text from a file at a given time.I used ftell() and fseek() to achieve this. #include //// include required header files #include int main() { …
-2
votes
1 answer

fseek() crossing file limit and not terminating

In the last while loop, every 5th character stored in the file should be printed, but the loop is going on indefinitely and not terminating. the feof() function should return 1 on reaching END OF FILE and the loop should be exited but the loop is…
daljinder singh
  • 177
  • 1
  • 9
-2
votes
1 answer

exc_bad_access caused by sprintf

I'm getting an error exc_bad_access in xcode when executing the following code. The error is caused by the following line: //Add new line at beginning of hex decode p += sprintf(p, "%s", "\n"); Could this be because when the pointer *p is created…
Ke.
  • 2,484
  • 8
  • 40
  • 78
-2
votes
1 answer

fwrite() method does not work properly

I' m trying to write to a file. It' s created properly but can not write nothing. On debug mode, I can see all attributes of object which I want to write. My method is so short, I used fseek method before writing. void File::add(record *ptr){ …
alperk
  • 15
  • 3
-2
votes
3 answers

perl file read, truncate

I am trying to modify a config file. I first read it into @buffer, depending on a regex match. The modified buffer gets written back on disk, in case the file got smaller, a trunciation is done. Unfortunatly this does not work, and it already…
drahnr
  • 6,782
  • 5
  • 48
  • 75
-3
votes
1 answer

Read len bytes of a file at offset and write it to FILETIME

Is there any possibility to read sth from a binary file when knowing only the size of the element that should be red and the offset (in hexa)? For example, if I want to read a FILETIME variable of 8 bytes, that has offset 0x001C, how do I approach…
-3
votes
1 answer

Reading files using fseek , fread and pointers

I'm trying to manipulate images using c, and trying to fully understand fseek() and fread() mechanisms. Why fseek did not change the address of point even it affected the fread function but did not change the point address or increase it? Here is a…
IDEN
  • 21
  • 1
  • 9
-3
votes
1 answer

How to acess specific parts of files and use it in C programming?

I am learnin how to program in C, and I've been having a hard time with using files. How can I do for example, there are two files. On it There are names and grades, from 1 to 10 of students. Like: John 10 John 5 Alex 6 Alex 9 Mary 8 …
-3
votes
1 answer

rewind and fseek don't work - C

int main() { FILE *file1, *file2; char filename[] = "test.xml"; char c; int line = 1; //open file in read mode file1 = fopen(filename, "r"); c = getc(file1); while (c != EOF){ printf("%c", c); c = getc(file1); } …
moth
  • 345
  • 1
  • 13
-4
votes
3 answers

C binary read and write file

I am using a binary file for reading an array of integers, then each even integer x should become 2 * x and each odd integer x should become 3 * x. When I am doing this it always read the 2nd integer (which is 2). Any idea? #include…
-4
votes
1 answer

Read files in C

Can any one tell me that, how do we read a specific portion of file using c. I have a file of 1000 Characters and I want to read it in parts eg: First 0 to 100 Characters and then 101 to 200 and so on. I have tried fread() and fseek() but couldn't…
Casper
  • 77
  • 4
-4
votes
1 answer

C programming , delete function

try to use fseek to modify the name but it cannot return what result i want which is the name cannot be modify and remain the same struct phonebook { char name[20]; }; struct phonebook a; char temp[20]; cpPtr=fopen("name.txt","rb");//open the…
BEAR
  • 1
1 2 3
27
28