popen vs fopen [Archive] - C Board

PDA

View Full Version : popen vs fopen


esme
11-21-2002, 08:17 AM
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:confused:

rotis23
11-25-2002, 10:37 AM
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.