Skip to content

Instantly share code, notes, and snippets.

@atpons
Created July 3, 2017 15:02
Show Gist options
  • Select an option

  • Save atpons/cda44a968dcd1a4a3565128090a665a7 to your computer and use it in GitHub Desktop.

Select an option

Save atpons/cda44a968dcd1a4a3565128090a665a7 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void intfrac(double input, int *ipart, double *dpart) {
int i = (int)input;
double d = (double)input - i;
ipart = &i;
dpart = &d;
}
int main() {
int *ipart = 0;
double *dpart = 0, input;
printf("> ");
scanf("%lf", &input);
intfrac(input, ipart, dpart);
printf("%lf = %d + %lf\n", input, *ipart, *dpart);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment