s7on3d
Jan 12, 2008, 10:48 AM
Hi everyone,
I'm pretty new to my mac, and also relatively new to programming... First year engineering student :)
I've written the following program as a command line program in C with Xcode:
int main(int argc, char *argv[]) // MAIN FUNCTION!!
{
int i;
for (i=0;i<argc;i++)
{
printf("argv[%d]: %s\n",i,argv[i]);
}
return 0;
}
Which should receive input as a set of strings from the command line when the program is run, then print it back out.
My question is how do I run the program (I assume from the terminal...) and pass on the parameters (in this case just a sentence)?
After quite a bit of playing around I've managed to successfully reach the right directory in the terminal, and open the program (using the "open" command), but I can't work out how to send it the parameters...
Thanks in advance,
Ilan
I'm pretty new to my mac, and also relatively new to programming... First year engineering student :)
I've written the following program as a command line program in C with Xcode:
int main(int argc, char *argv[]) // MAIN FUNCTION!!
{
int i;
for (i=0;i<argc;i++)
{
printf("argv[%d]: %s\n",i,argv[i]);
}
return 0;
}
Which should receive input as a set of strings from the command line when the program is run, then print it back out.
My question is how do I run the program (I assume from the terminal...) and pass on the parameters (in this case just a sentence)?
After quite a bit of playing around I've managed to successfully reach the right directory in the terminal, and open the program (using the "open" command), but I can't work out how to send it the parameters...
Thanks in advance,
Ilan
