Thread: Creating a file with a program

  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
    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,164
    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,897
    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
    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,897
    Macintosh before they began to use Darwin as the environment behind OS X.
    My best code is written with the delete key.

  7. #7
    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,897
    >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, 01: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, 10: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, 06:39 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM