diff --git a/02-pass-by-ref/no-ref.cpp b/02-pass-by-ref/no-ref.cpp new file mode 100644 index 0000000..00048ef --- /dev/null +++ b/02-pass-by-ref/no-ref.cpp @@ -0,0 +1,20 @@ +#include + +struct A +{ + char str[16]; +}; + +int len(struct A a) +{ + int count; + for(count = 0; a.str[count] not_eq '\0'; ++count); + return count; +} + +int main() +{ + struct A a = { .str = "Hello, World!" }; + int res = len(a); + return EXIT_SUCCESS; +} diff --git a/02-pass-by-ref/ref.cpp b/02-pass-by-ref/ref.cpp new file mode 100644 index 0000000..8d77cec --- /dev/null +++ b/02-pass-by-ref/ref.cpp @@ -0,0 +1,20 @@ +#include + +struct A +{ + char str[16]; +}; + +int len(struct A &a) +{ + int count; + for(count = 0; a.str[count] not_eq '\0'; ++count); + return count; +} + +int main() +{ + struct A a = { .str = "Hello, World!" }; + int res = len(a); + return EXIT_SUCCESS; +}