Reading and writing from/to files not in project folder in C?

Discussion in 'Programmer's Corner' started by blah2222, Aug 4, 2011.

  1. blah2222

    Thread Starter Distinguished Member

    May 3, 2010

    I am running NetBeans on my Mac OS X and have written a program in C. I am using file I/O and I would like to have the ability of reading from files outside the directory as well as write files to specific folders outside the directory.

    Does anyone know what the syntax for that is?

    P.S. It would also be cool if I could run the application without having to go through NetBeans,is there any way that I could go about doing this on a Mac using some sort of executable file, (not in Terminal)?

    Thanks a bunch!
  2. kavli

    New Member

    Aug 1, 2011
    How are you opening your output files? fopen?
    If you prepend the path with a leading /, then you give the absolute path.
    Of course you need write permissions for the path you're giving.

    -- K