From d26fff3644a29abf8af6c5bed462067a56b24647 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Tue, 15 Mar 2016 21:05:49 +0100 Subject: [PATCH] =?UTF-8?q?Suppl=C3=A9ment=20exercices=20cours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- P84.c | 23 +++++++++++++++++++++++ P86.c | 11 +++++++++++ 2 files changed, 34 insertions(+) create mode 100644 P84.c create mode 100644 P86.c diff --git a/P84.c b/P84.c new file mode 100644 index 0000000..78f8bd7 --- /dev/null +++ b/P84.c @@ -0,0 +1,23 @@ +/* Allocations dynamiques */ + +#include +#include + +void init(int *tab, int n) { + int i; + for (i = 0; i < n; i++) { + tab[i] = i; + printf("tab[%d]=%d\n", i, tab[i]); + } +} + +int main() { + int i, n, *tab; + printf("Saisissez n : "); + scanf("%d", &n); + tab = (int *) malloc(n * sizeof(int)); + init(tab, n); + + return 0; +} + diff --git a/P86.c b/P86.c new file mode 100644 index 0000000..f9b64cb --- /dev/null +++ b/P86.c @@ -0,0 +1,11 @@ +/* Arguments */ + +#include +#include + +int main(int argc, char *argv[]) { + int i; + for (i = 0; i < argc; i++) { + printf("argv[%d]=%s\n", i, argv[i]); + } +}