1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-08-08 13:25:12 +00:00
Files
kickc/src/test/kc/struct-ptr-31.kc

32 lines
536 B
C

// Example of a struct containing an array
struct Person {
char id;
char[16] name;
};
struct Person[] persons = {
{ 4, "jesper" },
{ 7, "henriette" }
};
void main() {
print_person(persons);
print_person(persons+1);
}
const char* SCREEN = 0x0400;
char idx = 0;
char[] DIGIT = "0123456789";
void print_person(struct Person *person) {
SCREEN[idx++] = DIGIT[person->id];
SCREEN[idx++] = ' ';
for(byte i=0; person->name[i]; i++)
SCREEN[idx++] = person->name[i];
SCREEN[idx++] = ' ';
}