Thread: read from file problem

  1. #1
    Registered User
    Join Date
    Mar 2009

    read from file problem

    Is there any function (Low lewel I/O) which can read some length from file from start position.
    I need some function which Have 4 arguments. First is file descriptor or some pointer to file, second is buffer as character array of some lentgth, third argument will be start position and last argument will be length of string readed from file.

    example: my_function(fd, buffer, 10, 5);
    this function will read first 10 characters of text file start with 5'th character;

    If is end of file function must return only characters left to the end of file.
    If content of text file is: "This is my text file" and my_function(fd, buffer, 10, 20) - this function will return string = "y text file" and not string = "y text file#########" and # represent some other characters like \0, \n or whatever.

    Can anyone help me with this function?

    P.S. Sorry for my bad English.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    to read from the current position use fread
    to set the current position fsetpos or fseek
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. Read File Problem
    By lonewolf367 in forum C Programming
    Replies: 11
    Last Post: 11-30-2005, 10:32 AM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM