Click here to Skip to main content
15,917,652 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Let suppose I have 2 files first.cpp and second.cpp in a folder. Each file takes 2 command line arguments that is integers. I want to make the make file named "Robot" So that I can directly run the program like following:::

Robot first 123412 1212

Or

Robot second 4124 214214

PLease help me. I have searched everywhere but didnot find the exact commands....
Posted
Updated 6-Sep-11 10:42am
v3

You cannot really do that... if I understand your question correctly.

I guess you presently have two programs that can be used like that:
first 123412 1212

or
second 4124 214214


and you want a single program but specify in first argument which "function" to use.

If this is want you want to do, then you have to rename existing main in first.cpp and second.cpp and create a third file that would parse the command line and call the appropriate function depending on the first argument.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 6-Sep-11 19:58pm    
This is just a bad idea of OP based on misunderstanding of how a C++ projects are built and run. My 5 for your explanation.
OP could better use some interpretive language; I would suggest Python, for example.
--SA
Espen Harlinn 7-Sep-11 4:44am    
Good reply :)
It's usually a good idea to take a look at the manual, so to get you started take a look at the sample on the top of this page:
Simple-Makefile[^]

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Sep-11 19:59pm    
Yes, it's good, my 5. Not sure it will really help OP though (but the knowledge itself will not hurt). Please see the answer by Philippe and my comment.
--SA
Espen Harlinn 7-Sep-11 4:43am    
You really have to look at my answer in the context of the original question to make any sense of it:"Hi i made two .cPP files and i want to make makefile of it. please help me..."

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900