Find the answer to your Linux question:
Results 1 to 4 of 4
hey im programming in c , and i want to open a new EMPTY file , im using the "open" system call . this is my code: Code: fd=open(filename, O_WRONLY ...
  1. #1
    Just Joined!
    Join Date
    Nov 2006
    Posts
    33

    open empty file

    hey
    im programming in c , and i want to open a new EMPTY file , im using the
    "open" system call . this is my code:
    Code:
     fd=open(filename, O_WRONLY | O_CREAT);
    but this open me the old file (if there is such one) ... and i want to open a new empty one..

    how can i do this ?
    thanks !

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Do this at the command line:
    Code:
    man truncate
    man ftruncate
    and all will be revealed.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Better to "man 2 open" and learn about O_TRUNC.

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Better to "man 2 open" and learn about O_TRUNC.
    Correct. I don't know what I was thinking. Furrfu.
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...