mirror of
https://gitlab.com/blau_araujo/cblc.git
synced 2025-05-09 18:16:37 -03:00
exemplos de acesso aos argumentos de linha de comando
This commit is contained in:
parent
b7b146aefa
commit
5c66f0e140
1 changed files with 13 additions and 12 deletions
|
@ -1,22 +1,23 @@
|
|||
#include <stdio.h>
|
||||
|
||||
|
||||
void print_list(char *list[]) {
|
||||
int i = 0;
|
||||
while (list[i] != NULL) {
|
||||
printf("[%d] => %s\n", i, list[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Imprime listas de strings...
|
||||
void print_list(char *list[]);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
// O vetor de argumentos (argv) é um vetor de strings
|
||||
// terminado com um ponteiro nulo (NULL)...
|
||||
|
||||
for (int i = 0; i < argc; i++)
|
||||
printf("argv[%d] = %s\n", i, argv[i]);
|
||||
|
||||
print_list(argv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print_list(char *list[]) {
|
||||
int i = 0;
|
||||
while (list[i] != NULL) {
|
||||
printf("[%d] => %p => %s\n", i, list[i], list[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue