From 2980a5878460ac07152ef6daa608adcb22644c5b Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 13 Dec 2024 23:30:22 +0300 Subject: [PATCH] Starting to work with pointers --- c_modern_approach/Pointers/theory.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 c_modern_approach/Pointers/theory.c diff --git a/c_modern_approach/Pointers/theory.c b/c_modern_approach/Pointers/theory.c new file mode 100644 index 0000000..a730bb0 --- /dev/null +++ b/c_modern_approach/Pointers/theory.c @@ -0,0 +1,16 @@ +#include +void decompose(double, long *, double *); + +int main() { + long mp; + double rm; + double x = 3.141234; + printf("%ld, %f\n", mp, rm); + decompose(x, &mp, &rm); + printf("%ld, %f\n", mp, rm); +} + +void decompose(double x, long *int_part, double *frac_part) { + *int_part = (long)x; + *frac_part = x - *int_part; +}