Created
November 2, 2016 00:48
-
-
Save luizamboni/2c6099c59ea93014d6873264cc6e0d78 to your computer and use it in GitHub Desktop.
aed trabalho
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdio.h> | |
#include <stdlib.h> | |
/* | |
para comilar no linux use: | |
g++ ead.cpp | |
e para rodar: | |
./a.out -a 1 | |
./a.out -a 2 | |
./a.out -a 3 | |
*/ | |
using namespace std; | |
int main(int argc, char* argv[]) { | |
char* arg_a; | |
int switch_option; | |
printf( "test first argment! \"%s\" \n", argv[1]); | |
if (string(argv[1]) == string("-a")) { | |
arg_a = argv[2]; | |
} | |
printf( "arg_a is \"%s\" \n", arg_a); | |
if (string(arg_a) == "1") { | |
switch_option = 1; | |
} else if (string(arg_a) == "2") { | |
switch_option = 2; | |
} else { | |
switch_option = 3; | |
} | |
printf( "switch options \"%i\" \n", switch_option); | |
switch(switch_option){ | |
case 1: | |
cout << "has passed \"a\" as 1 argment\n"; | |
break; | |
case 2: | |
cout << "has passed \"a\" as 2 argment\n"; | |
break; | |
default: | |
cout << "no one valid argument was passed\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment