Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-04-29
7
Medium Priority
?
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

704 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