Thread: About using file open

  1. #1
    Registered User
    Join Date
    Feb 2018
    Posts
    24

    About using file open

    hey all
    i am curious about why even we use fopen even we have file* to point the current file. i mean what does "opening file" mean" ? what is the real point at opening file ?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,675
    You mean as opposed to say writing uncontrollably to random sectors on the disk?

    Like a lot of things, file systems follow a transactional model where you have begin/end, open/close or acquire/release.

    The first step is to get the resource, which may fail because it doesn't exist, is already in use, or you don't have permission.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Feb 2018
    Posts
    24
    not fully but partly i kinda understand so actually you are saying it is important to take memory from disk so fopen does this right ?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,675
    fopen returns a token (in this case, it's a FILE*), which grants you permission to do other file operations like fgets, fread etc.

    It's your train ticket.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 05-13-2015, 05:46 PM
  2. Replies: 1
    Last Post: 03-10-2013, 09:47 PM
  3. Replies: 3
    Last Post: 03-08-2010, 02:43 PM
  4. Open File/Save File crashes on cancel?
    By Blackroot in forum Windows Programming
    Replies: 0
    Last Post: 08-02-2008, 02:16 AM
  5. Replies: 12
    Last Post: 03-10-2005, 07:48 PM

Tags for this Thread