ne**********@yahoo.co.in wrote:
please let me know
if am using command line arguments, how to send arguments to a C
program if i am working on ubuntu
say for example
suppose name of my program is prog.c
if argc=3
then how to send those three arguments(pt1.txt,pt2.txt,pt3.txt) to
prog.c through command prompt if i am working on linux
please reply urgently
We are not your contract workers. We try to help but we cannot help you
with your last minute problems.
If your program executable is named 'prog', to give it the arguments
pt1.txt, pt2.txt and pt3.txt do at the command prompt and with the
programs's directory as your working directory:
prog pt1.txt pt2.txt pt3.txt
The general formula is:
PROGRAME [ARG 1] [ARG 2] [...]
You first type the program's name, as you would for any other program
and then type out it's arguments one after the other, separated by a
space. This will do fine for starting out. Later on you might like to
write a general purpose arguments processor along the lines of getopt
and others that handle more complicated formats and conditions.
PS. Note that in the example above argc will be four, not three, as the
program's invocation name also counts as a parameter, a difference from
languages like Java.