read from file problem

This is a discussion on read from file problem within the C Programming forums, part of the General Programming Boards category; Is there any function (Low lewel I/O) which can read some length from file from start position. I need some ...

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    7

    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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    to read from the current position use fread
    to set the current position fsetpos or fseek
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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, 09:32 AM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21