Added foreach macro for dynamic arrays
This commit is contained in:
parent
611f5d5b5a
commit
9c7147354a
2 changed files with 19 additions and 0 deletions
17
examples/da_foreach.c
Normal file
17
examples/da_foreach.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#define LAZY_IMPL
|
||||
#include "../lazy.h"
|
||||
|
||||
int main() {
|
||||
srand(time(NULL));
|
||||
Lz_DA(int) nums = {0};
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
lz_da_append(nums, rand()%100);
|
||||
}
|
||||
|
||||
lz_da_foreach(int, x, nums) {
|
||||
printf("%d\n", *x);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue