Thread: file pointer

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    1

    file pointer

    please tell a details of the structure of a file pointer defined in stdio.h.please describe the macros used here.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The details are compiler/library dependent.

    From a perspective of C as a language (eg the C standard) the FILE pointer is essentially an opaque type - programmers rarely need to know the details.

    If you do need to know the details, simply examine the stdio.h that comes with your compiler. Just keep in mind that the details will be different for another compiler (or even, potentially, for a different version of your compiler).
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User ungalnanban's Avatar
    Join Date
    Feb 2010
    Location
    Chenai
    Posts
    12

    Thumbs up

    See the following code.

    This is the predefine FILE structure. in stdio.h


    Code:
    typedef struct {
    	char *fpos; /* Current position of file pointer (absolute address) */
            void *base; /* Pointer to the base of the file */
            unsigned short handle; /* File handle */
            short flags; /* Flags (see FileFlags) */
            short unget; /* 1-byte buffer for ungetc (b15=1 if non-empty) */
            unsigned long alloc; /* Number of currently allocated bytes for the file */
            unsigned short buffincrement; /* Number of bytes allocated at once */
    } FILE;
    Last edited by ungalnanban; 03-03-2010 at 11:54 PM.

  4. #4
    Registered User
    Join Date
    Apr 2009
    Posts
    66
    You can see the details in this file /usr/include/libio.h
    Refer this site for more details
    http://tigcc.ticalc.org/doc/stdio.html#FILE
    Last edited by Alexander jack; 03-03-2010 at 11:55 PM.

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Just note that the preceding two posts are specific to a particular compiler and/or library. If your compiler/library differs from the ones used by ungalnanban or Alexander jack, then the contents of stdio.h may differ (and usr/include/libio.h may not even exist).
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  6. #6
    Registered User
    Join Date
    Apr 2009
    Posts
    66
    grumpy is right , I gave solution for GCC 4.1.2.
    may I know which compiler u r Mr.u.unmesh?

    You can use any compiler , but I hope that there is no big and notable difference would be
    there in the structure of FILE. I am very sure that the link itself will give you a clear picture

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. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  5. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM

Tags for this Thread