Starting to work with pointers
This commit is contained in:
parent
7c8e99f5aa
commit
2980a58784
1 changed files with 16 additions and 0 deletions
16
c_modern_approach/Pointers/theory.c
Normal file
16
c_modern_approach/Pointers/theory.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <stdio.h>
|
||||
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;
|
||||
}
|
Loading…
Reference in a new issue