On Thu, 2013-05-16, Pinnerite wrote:
> I make great use of a 'C' program written by someone else. It works
> invisibly but creates files named by itself. I would like to grant the user
> the option to create their own filenames and the paths for the created
> files.
Careful with the terminology. "path" and "filename" are almost
synonyms.
Programs (in Unix) which hardcode the output paths do indeed suck.
There are a few better design choices, assuming the program needs to
generate more than one file:
% foo # creates files in current directory
% foo --src bar.c --hdr bar.h
# the number of files is small and known
% foo --dest /tmp/bar/
# create /tmp/bar/ if needed and leave any files there
% foo --prefix /tmp/bar
# files are called bar.01, bar.02, ...
And others. You don't say what the program does, and it's hard to guess.
> My question is in which environment to tackle this: C or C++?
C, of course. Why would you add an extra work load by porting it to
C++? It's not as if C cannot write to files.
Followup set.
> I have not programmed for some time but keep up to date as best I can. I
> have a limited experience in using OO languages but I do not want to devote
> myself into becoming an expert in either language just getting to grips with
> the bits that I need for this exercise.
You don't need to learn OO for this.
> I should add that this is a Linux exercise.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/
snipabacken.se> O o .