Created
August 20, 2020 01:41
-
-
Save caloni/5b9ccc66722a1b235f4aab8251822cdb to your computer and use it in GitHub Desktop.
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
/** Interpreta argumentos da linha de comando (versão raiz). | |
@author Wanderley Caloni <wanderley.caloni@bitforge.com.br> | |
@date 2018-08 | |
--- --- | |
argv: | * |--> | * | "testbin" | |
--- --- | |
--- | |
| * | "foo" | |
--- | |
--- | |
| * | "100" | |
--- | |
--- | |
argc: | 3 | | |
--- | |
*/ | |
#include <stdlib.h> | |
#include <string.h> | |
const char* GetArg(int argc, char* argv[], const char* arg) | |
{ | |
for (int i = 1; i < argc; ++i) | |
{ | |
if( strcmp(argv[i], arg) == 0 ) | |
{ | |
if( i < argc - 1 ) | |
return argv[i+1]; | |
else | |
return ""; | |
} | |
} | |
return NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment