Make file for a program that has a main function taking command line arguments

Hi all!

I have a program with a main function that takes command line arguments.

It looks like

int main(int argc, char ** argv) {
// code here
}

I want to write a makefile that generates an executable for this program called myprog. When I run this program I want to be able to give command line arguments to the main function.

What do I need in my makefile for doing this? I can write a makefile for a program that takes no arguments but I dont know how to write the makefile in this case.

Thanks in advance!

manadAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
_corey_Connect With a Mentor Commented:
The makefile should not make a difference.

You simply provide the paramaters at runtime.

yourprogram param1 param2

0
 
AxterConnect With a Mentor Commented:
If you're using VC++ 6.0, you can make this setting by pressing Alt-F7, and then click the DEBUG tab, and fill in Program-Argument field.

What compiler are you using, and what's your OS?
0
 
manadAuthor Commented:
I am using g++ for compilation on Sun-Solaris platform.

So basically if the target is called 'myprog' then all I need to do for running the program is...

myprog param1 param2

Is this correct?


0
 
CoolBreezeConnect With a Mentor Commented:
yup, if I am not wrong.
and yes, the makefile should be the same.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.