Skip to content
Snippets Groups Projects
Verified Commit 4f07b04c authored by orestis.malaspin's avatar orestis.malaspin
Browse files

added details

parent a22a1f04
No related branches found
No related tags found
No related merge requests found
......@@ -53,10 +53,8 @@ argv[3] == "file.txt"
- Fonctions pour faire des conversions:
```C
int atoi(const char *nptr);
long atol(const char *nptr);
long long atoll(const char *nptr);
double atof(const char *nptr);
int atoi(const char *nptr); // de la chaîne en entier
double atof(const char *nptr); // de la chaîne en nombre à virgule flottante
int snprintf(char *str, size_t size,
const char *format, ...);
// str: buffer, size: taille en octets max à copier,
......@@ -79,8 +77,10 @@ int main(int argc, char **argv) {
fprintf(stderr, "usage: %s name age\n", progname);
return EXIT_FAILURE;
}
char *name = argv[1];
int age = atoi(argv[2]);
// argv[0] est le nom du programme on l'ignore
// le 1er argument est une chaîne de caractères (pas de conversion)
char *name = argv[1];
int age = atoi(argv[2]); // le 2e argument est un entier (conversion)
printf("Hello %s, you are %d years old.\n", name, age);
return EXIT_SUCCESS;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment