dynamic file handling help

This is a discussion on dynamic file handling help within the C Programming forums, part of the General Programming Boards category; I'm having problem understanding the concepts of ftell(),fseek etc. i need to know a)the general syntax of ftell() is ....n=ftell(file_pointer); ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    25

    dynamic file handling help

    I'm having problem understanding the concepts of ftell(),fseek etc.
    i need to know
    a)the general syntax of ftell() is ....n=ftell(file_pointer);
    supppose for a file to which i have already written the following integers 1,2,3
    and after having written the last integer i use ftell what should be the value of n ?

    b) what exactly are they talking about when the tell that ftell returns the current position of the file?

    c) when i write a integer or character to a file how many bytes of data has my compiler written ? on what does it depend?

  2. #2
    Rabble Rouser Slacker's Avatar
    Join Date
    Dec 2005
    Posts
    116
    >after having written the last integer i use ftell what should be the value of n ?
    Try it and see.

    >what exactly are they talking about when the tell that ftell returns the current position of the file?
    When you open a file, there's a value attached to that file that represents where you are, a pointer if you will. That pointer tells you where the next read or write will begin, and with the lesser positioning functions, that pointer is nothing more than an integral value that's a byte index. So if you have a 40 byte file and the next write will write to the end of the file, the position indicated would probably be 40.

    >on what does it depend?
    It depends on the size of the type you're writing. A char is always 1, but an int would be sizeof(int), which on your machine would probably be 4.

  3. #3
    Bond sunnypalsingh's Avatar
    Join Date
    Oct 2005
    Posts
    162
    Read about ftell

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM
  4. Dynamic memory allocation for file handling
    By prashanth_sh in forum C Programming
    Replies: 2
    Last Post: 11-07-2002, 05:50 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM

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