how does fseek work with the set of arguments specified as below?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pallavi27
    New Member
    • Mar 2007
    • 14

    how does fseek work with the set of arguments specified as below?

    hello everybody,
    i want to know that if i use the statement fseek(fp,column-3,1); in my program where fp is the file pointer,column-3 is the no of columns specified by the user
    -3 and third argument is 1. please explain me where will the file pointer be placed after this statement gets executed.this is urgent if possible please tell me as soon as possible.thanky ou.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    From position 1 in the file (the SECOND byte), add the value in column-3.

    Now the question is: Does your column-3 contain the NUMBER of columns or the number of bytes in the number of columns?

    fseek ASSUMES the second argument is the OFFSET from the third argument.

    Comment

    • pallavi27
      New Member
      • Mar 2007
      • 14

      #3
      Originally posted by weaknessforcats
      From position 1 in the file (the SECOND byte), add the value in column-3.

      Now the question is: Does your column-3 contain the NUMBER of columns or the number of bytes in the number of columns?

      fseek ASSUMES the second argument is the OFFSET from the third argument.
      thanks a lot much for clearing my doubt. but the question you ve put i need an answer to that also.i think it should be no of columns but the data i am using is integers so it might also be no of bytes in the no of columns.i am using this pointer for an array of integers.so please tell me that what assumtion should i make.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Do not make assumptions. If your columns are integers and you have N integers in the columns, then the column size is:

        N * sizeof(int)

        If you have Y columns, then the size of those columns is:

        Y * N * sizeof(int)

        That is what you use in fseek.

        Comment

        Working...