mirror of
https://gitlab.com/blau_araujo/cblc.git
synced 2025-05-10 02:26:36 -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>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Imprime listas de strings...
|
||||||
void print_list(char *list[]) {
|
void print_list(char *list[]);
|
||||||
int i = 0;
|
|
||||||
while (list[i] != NULL) {
|
|
||||||
printf("[%d] => %s\n", i, list[i]);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
// O vetor de argumentos (argv) é um vetor de strings
|
for (int i = 0; i < argc; i++)
|
||||||
// terminado com um ponteiro nulo (NULL)...
|
printf("argv[%d] = %s\n", i, argv[i]);
|
||||||
|
|
||||||
print_list(argv);
|
print_list(argv);
|
||||||
|
|
||||||
return 0;
|
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