blob: b2acd64cb2220ebee96c3b061f8e27511aba2bc2 [file] [log] [blame]
Johnny Chend5e111c2010-09-15 22:27:29 +00001//===-- main.cpp ------------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include <cstdlib>
11#include <string>
12#include <fstream>
13
14int
15main(int argc, char const *argv[])
16{
17 char const *cptr = NULL;
18 // The program writes its output to the "output.txt" file.
19 std::ofstream outfile("output.txt");
20
21 for (unsigned i = 0, e = sizeof(argv); i < e; ++i) {
22 if ((cptr = argv[i]) == NULL)
23 break;
24
25 std::string str(cptr);
26 if (i == 1 && "A" == str)
27 outfile << "argv[1] matches\n";
28
29 if (i == 2 && "B" == str)
30 outfile << "argv[2] matches\n";
31
32 if (i == 3 && "C" == str)
33 outfile << "argv[3] matches\n";
34 }
35
36 if (::getenv("MY_ENV_VAR")) {
37 std::string MY_ENV_VAR(getenv("MY_ENV_VAR"));
38 if ("YES" == MY_ENV_VAR) {
39 outfile << "Environment variable 'MY_ENV_VAR' successfully passed.\n";
40 }
41 }
42
43 return 0;
44}