GIT.Harvie.CZ
/
svn
/
Cll1h
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
some locale related experiments
[svn/Cll1h/.git]
/
demos
/
for_range.c
diff --git
a/demos/for_range.c
b/demos/for_range.c
index 6aedae7b7e32d7d40a698a59c6c76d622faf72af..c96f24cb53b05768f55c127d1f1010f6246d05c5 100644
(file)
--- a/
demos/for_range.c
+++ b/
demos/for_range.c
@@
-2,22
+2,50
@@
program
{
program
{
- int i;
+ int i
,j=1
;
- printf("for_range(i,0,1)");
- for_range(i,0,1) printf(" [%d]",i);
+ echo("Just plain vanilla auto-increment:\tfor_range(i,1,5)");
+ for_range(i,1,5)
+ {
+ printf(" [%d]",i);
+ }
+ print("");
- printf("\nfor_range(i,1,0)");
- for_range(i,1,0) printf(" [%d]",i);
+ echo("Single-evaluation of macro argument:\tj=1; for_range(i,0,j++)");
+ for_range(i,0,j++)
+ {
+ printf(" [%d]",i);
+ }
+ print("");
- printf("\nfor_range(i,1,1)");
- for_range(i,1,1) printf(" [%d]",i);
+ echo("Just plain vanilla auto-decrement:\tfor_range(i,1,0)");
+ for_range(i,1,0)
+ {
+ printf(" [%d]",i);
+ }
+ print("");
- printf("\nfor_range(i,1,5)");
- for_range(i,1,5) printf(" [%d]",i);
+ echo("Single iteration is possible too:\tfor_range(i,1,1)");
+ for_range(i,1,1)
+ {
+ printf(" [%d]",i);
+ }
+ print("");
- printf("\nfor_range(i,5,1)");
- for_range(i,5,1) printf(" [%d]",i);
+ echo("Yet another example of macro safety:\tj=2; for_range(i,5,--j)");
+ for_range(i,5,--j)
+ {
+ printf(" [%d]",i);
+ }
+ print("");
- printf("\n");
+ echo("Nesting of this macro seems to be safe:\tfor_range(i,1,3) for_range(j,3,1)");
+ for_range(i,1,3)
+ {
+ for_range(j,3,1)
+ {
+ printf(" [%d,%d]",i,j);
+ }
+ }
+ print("");
}
}
This page took
0.211393 seconds
and
4
git commands to generate.