Added foreach macro for dynamic arrays

This commit is contained in:
cannoli-fruit 2026-07-12 20:40:24 -04:00
commit 9c7147354a
2 changed files with 19 additions and 0 deletions

17
examples/da_foreach.c Normal file
View 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);
}
}