author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Tue, 13 Oct 2009 19:03:36 +0200 | |
changeset 108 | d6a52e0152fb |
child 140 | 05d42a3737a4 |
permissions | -rw-r--r-- |
108
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
1 |
/** |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
2 |
* Compont literals in C aka anonymous arrays |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
3 |
* |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
4 |
*/ |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
5 |
|
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
6 |
#include <stdio.h> |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
7 |
#include <stdlib.h> |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
8 |
#include <assert.h> |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
9 |
|
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
10 |
static void show (char *arr[]) |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
11 |
{ |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
12 |
int i = 0; |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
13 |
|
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
14 |
assert (arr != NULL); |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
15 |
while (arr[i] != NULL) { |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
16 |
printf ("arr[%d] = %s\n", i, arr[i]); |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
17 |
i++; |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
18 |
} |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
19 |
} |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
20 |
|
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
21 |
int main (int argc, char **argv) |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
22 |
{ |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
23 |
show ((char *[]) { |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
24 |
"Here", "we", "go", "again", NULL}); |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
25 |
return EXIT_SUCCESS; |
d6a52e0152fb
Compont Literals in C aka Anonymous arrays
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
26 |
} |