Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Advice on an approach to a problem

32 views
Skip to first unread message

Pinnerite

unread,
May 16, 2013, 7:36:43 AM5/16/13
to
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.

My question is in which environment to tackle this: C or C++?
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.

I should add that this is a Linux exercise.

Any suggestions? TIA

--
___________________________________________________

Mageia 2 for x86_64, Kernel: 3.4.34-desktop-1.mga2
KDE version 4.8.5 Running on an AMD 4-core processor

Jorgen Grahn

unread,
May 16, 2013, 8:00:07 AM5/16/13
to
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 .
0 new messages