Thread: popen vs fopen

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    1

    Question popen vs fopen

    Hello,
    i am trying to find out the difference between popen() and fopen() for a linux based code. Can't seem to find reference to popen anywhere!!
    in my code i use:
    sprintf(dat_file,"%s.dat",nextfile);
    fpout=fopen(dat_file,"w")

    but i actually want to write the dat_file to a different location. The program i am in goes to a different directory (the data directory) to look for data and works with it in that location, so how can i write dat_file to the working directory where the code was first called (as i do not have write permissions in the data directory) is popen the way forward??
    THANKYOU!
    emma

  2. #2
    Registered User
    Join Date
    Aug 2002
    Posts
    351
    does popen actually run a shell? like system?

    i thought popen was safer than system because it doesn't run a shell.

    yes, you can call me a pedant.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. popen and fgets, underflow!
    By henrikstolpe in forum Linux Programming
    Replies: 0
    Last Post: 02-06-2009, 03:39 AM
  2. help with stat() and fopen()
    By movl0x1 in forum C Programming
    Replies: 6
    Last Post: 07-25-2007, 05:28 AM
  3. fopen help.
    By chriscolden in forum C Programming
    Replies: 17
    Last Post: 01-13-2006, 06:27 AM
  4. popen()
    By Cactus_Hugger in forum Windows Programming
    Replies: 2
    Last Post: 10-22-2005, 03:16 PM