I have a working program but now I have to use the int argc
and char *argv[]
parameters to main
. Whenever I try to do this it gives me errors that it cannot save. Is there any way to make argc
and argv
work in Eclipse?
Asked
Active
Viewed 8,141 times
6

Keith Thompson
- 254,901
- 44
- 429
- 631

gamergirl22
- 149
- 1
- 4
- 16
-
2"I try to do this it gives me errors that it cannot save". Would you care to tell exactly what the errors say? – Bernd Elkemann Feb 14 '12 at 17:18
-
C++ is case-sensitive; `main` and `MAIN` are two distinct identifiers, for example. I've edited your question accordingly. – Keith Thompson Feb 14 '12 at 20:26
1 Answers
7
I guess your problem is that you don't know hot to pass argument to you program, when you execute it through eclipse isn't it ?
If that is what you want, read the following.
Click on the "Project->Properties" then in "Run/Debug settings" click on the "New button". Choose C++ application. Here you can see that there are 4 tabs, and the second tab is called "arguments". In this tab you can see a textarea. Type your application's argument there, and click "OK". When you will execute your application thanks to the "play" button of eclipse, your program will be called with arguments.

Adrien BARRAL
- 3,474
- 1
- 25
- 37
-
Does Eclipse not provide a way to specify command-line arguments when you execute the program? Setting the arguments as part of the project configuration seems rather silly. Another option is to run the program from a command line. – Keith Thompson Feb 14 '12 at 20:27
-
I am agree with you, that is silly. Personaly, i run my programs from the command line as you said. – Adrien BARRAL Feb 15 '12 at 06:50