Skip to content

Instantly share code, notes, and snippets.

View 17twenty's full-sized avatar

Nick Glynn 17twenty

View GitHub Profile
@17twenty
17twenty / learn_something_new.c
Created May 23, 2014 14:46
Learn something new about passing arrays, and how awful the syntax can be :D
/* gcc -std=c99 due to loop initialiser - stupid GCC defaulting to C89 :( */
#include <stdio.h>
#define ARRAY_SIZE(x) \
((sizeof(x) / sizeof(x[0])))
void count_and_process_items(unsigned int (*array)[10])
{
for (int i = 0; i < ARRAY_SIZE(*array); ++i) {
printf("Item %d = %d\n", i, (*array)[i]);