Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-04-29
7
Medium Priority
?
206 Views
Last Modified: 2011-09-20
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!

0
Comment
Question by:manad
7 Comments
 
LVL 8

Accepted Solution

by:
_corey_ earned 102 total points
ID: 10953921
The makefile should not make a difference.

You simply provide the paramaters at runtime.

yourprogram param1 param2

0
 
LVL 30

Assisted Solution

by:Axter
Axter earned 99 total points
ID: 10953965
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
 

Author Comment

by:manad
ID: 10954397
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
 
LVL 3

Assisted Solution

by:CoolBreeze
CoolBreeze earned 99 total points
ID: 10956195
yup, if I am not wrong.
and yes, the makefile should be the same.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question