Creating a file with a program

This is a discussion on Creating a file with a program within the C Programming forums, part of the General Programming Boards category; Hey, what is the code to create a file in a different directory than the one the C program is ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    28

    Creating a file with a program

    Hey, what is the code to create a file in a different directory than the one the C program is in? Say the program is in c:\x\yy, and I want the program to create a text file in c:\x\zz\top.

  2. #2
    c99
    c99 is offline
    Registered User
    Join Date
    Feb 2004
    Posts
    79
    fopen("full/path/to/dir/filename", "w");
    R.I.P C89

  3. #3
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161
    or

    fopen("full\\path\\to\\dir\\filename", "w");
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Or
    Code:
    fopen ( "full:path:to:dir:filename", "w" );
    Or some other implementation dependent way of specifying file structure paths. C doesn't care as long as the path eventually resolves to something valid.
    My best code is written with the delete key.

  5. #5
    c99
    c99 is offline
    Registered User
    Join Date
    Feb 2004
    Posts
    79
    Prelude.

    Which filesystem/OS uses colons as a separator?
    R.I.P C89

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Macintosh before they began to use Darwin as the environment behind OS X.
    My best code is written with the delete key.

  7. #7
    c99
    c99 is offline
    Registered User
    Join Date
    Feb 2004
    Posts
    79
    Cool. Yeah I was just informed that on IRC too.

    What was the equivalent of ../ then? ..:?
    R.I.P C89

  8. #8
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >What was the equivalent of ../ then?
    Clicking on the up arrow?
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 02:04 PM
  2. I'm not THAT good am I?
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-19-2006, 11:08 AM
  3. Replies: 9
    Last Post: 03-03-2006, 10:11 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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