Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cours_prog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yassin.elhakoun
cours_prog
Commits
4f07b04c
Verified
Commit
4f07b04c
authored
2 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
added details
parent
a22a1f04
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
slides/ligne_de_commande_c.md
+6
-6
6 additions, 6 deletions
slides/ligne_de_commande_c.md
with
6 additions
and
6 deletions
slides/ligne_de_commande_c.md
+
6
−
6
View file @
4f07b04c
...
...
@@ -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;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment