mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-08-11 02:25:17 +00:00
working on struct strategy
This commit is contained in:
24
src/test/kc/struct-11b.kc
Normal file
24
src/test/kc/struct-11b.kc
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
// Example of a struct containing an array
|
||||||
|
|
||||||
|
import "stdlib"
|
||||||
|
import "print"
|
||||||
|
|
||||||
|
struct Person {
|
||||||
|
unsigned long id;
|
||||||
|
char[3] initials;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Person jesper = { 111172, "jg" };
|
||||||
|
struct Person henry = { 280173, "hg" };
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
print_person(jesper);
|
||||||
|
print_person(henry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_person(struct Person person) {
|
||||||
|
print_dword_decimal(person.id);
|
||||||
|
print_char(' ');
|
||||||
|
print_str(person.initials);
|
||||||
|
print_ln();
|
||||||
|
}
|
Reference in New Issue
Block a user