Reputation: 6971
I direct you to Kernighan & Ritchie exercise 7.1
Write a program that converts upper case to lower case or lower case to upper case depending on the name it is invoked with,...
How can I invoke the same program with different names?
I am using Linux, so I am invoking a compiled program just by entering:
$./a.out
What should I be doing differently?
Upvotes: 6
Views: 546
Reputation: 12914
You could just copy it to a different file:
cp a.out myprogram1
cp a.out myprogram2
Wallah, your program has different names.
Upvotes: 2
Reputation: 399713
You should create a symbolic link, or just copy the executable of course:
Either
$ ln -s a.out A.out
or
$ cp a.out A.out
Then in your program's main()
, inspect argv[0]
to figure out how to act. This is a pretty useful technique, actually used often by production software.
Upvotes: 8