Questions tagged [lseek]

A linux C API function that repositions the offset of the open file associated with the file descriptor to the argument offset according to the directive.

81 questions
-1
votes
1 answer

Trouble working with file using lseek() read() and write()

i'm working on C in my university, i'm at the beggining working with buffers and this function so apolagize my lack of knowledge that i might show. I gotta do this project using lseek(), write() and read(). I wanted to read a file, and every letter…
César Pereira
  • 249
  • 4
  • 17
-1
votes
1 answer

C - Read struct in file

Hi I want to read some information in a struct that i wrote in file with fwrite but there's a problem I can't extract these information. I got 2 file tttfs.h : #include #include #include #include…
Jackie
  • 143
  • 1
  • 3
  • 8
-3
votes
3 answers

Why isn't lseek changing value? (C)

unsigned int file = open(argv[1], O_RDONLY); printf("%u\n", file); printf("%u\n", elf.offset); lseek(file, elf.offset, SEEK_SET); printf("%u", file); OutPut: 3 52 3 Shouldn't file be set to 52?
csguy
  • 1,354
  • 2
  • 17
  • 37
-3
votes
1 answer

Java read file line by line to a specific seek position

I want to read a file line by file to a specified seek position. It is easy to start reading from a certain seek position and read further till end. RandomAccessFile f = new RandomAccessFile("file.txt","r") f.seek(seek) This set file reading…
Shashwat Kumar
  • 5,159
  • 2
  • 30
  • 66
-3
votes
1 answer

Can't use lseek to add a space at the end of a file

I am trying to append some text to an already opened file. I'd like to append the pid number at the end of my file. For example: Lorem ipsum dolor sit amet orci aliquam. 14872. My code works fine except I am failing at making my program print the…
haunted85
  • 1,601
  • 6
  • 24
  • 40
-3
votes
3 answers

Getting a file's size in C with lseek?

I am trying to get the size of a file in C with the following operations... I am new to C This is my struct mem at the top of my file: struct mem {size_t size; }; Is this the correct set up with local variables/return statements and…
Surz
  • 984
  • 3
  • 11
  • 36
1 2 3 4 5
6