티스토리 뷰

Series

Add C++ Program Arguments [Eclipse]

More Code 2018. 6. 30. 09:56

사용환경 : MinGW (gcc 6.3.0), Eclipse CDT (Oxygen 4.7.0), Windows 10 x64


Eclipse CDT 환경에서 compile한 실행파일을 실행시켰을 때, arguments를 입력하는 방법을 알아보자.


아래와 같이 Program arguments를 입력하면 된다.


Run > Run Configurations > Create, manage, and run configurations > Arguments > Program arguments






Eclipse에서 Program arguments로 “Hello World”를 입력하고, 아래의 예제 프로그램을 실행시켜보자.


#include <iostream>

#include <cstdlib>

 

using namespace std;

 

int main(int argc, char **argv) {

       for (int var = 0; var < argc; ++var) {

              cout << var << " : " << argv[var] << endl;

       }

 

       return EXIT_SUCCESS;

}


아래와 같은 내용이 출력된다.


0 : C:\Source\Eclipse\Cpp2\Debug\Cpp2.exe

1 : Hello

2 : World



'Series' 카테고리의 다른 글

Setup GCC on Windows using MinGW  (0) 2018.07.02
Add C++ Program Arguments [CLion]  (0) 2018.06.30
Add C++ Command Arguments [Visual Studio]  (0) 2018.06.30
Set C++ Standard Option [CLion]  (0) 2018.06.30
Set C++ Standard Option [Eclipse]  (0) 2018.06.30
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함