Skip to content

Commit

Permalink
Another source example.
Browse files Browse the repository at this point in the history
  • Loading branch information
janpgit committed Apr 21, 2024
1 parent 013b777 commit 44967bd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions modules/program-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Code:

Also see:
- #solution argv-while.c
- #solution argv-while-v2.c
- #solution argv-for-v2.c

## :wrench: Print command line arguments (part II.)
Expand Down
9 changes: 9 additions & 0 deletions src/argv-while-v2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <stdio.h>

int
main(int argc, char **argv)
{
while (*argv++ != NULL) {
printf("'%s'\n", *(argv - 1));
}
}
4 changes: 2 additions & 2 deletions src/argv-while.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
int
main(int argc, char **argv)
{
while (*argv++ != NULL) {
printf("'%s'\n", *(argv - 1));
while (*argv != NULL) {
printf("'%s'\n", *argv++);
}
}

0 comments on commit 44967bd

Please sign in to comment.