Very simple Function using printf()
Hello again,
This code uses a simple function that takes two arguments and just prints them. This is easy when using two int (%d) arguments. However, I want to take two double arguments (i.e. integers with decimal points) but once I start messing with the format specifiers the output goes mental. What am I doing wrong?
Code:
#include <stdio.h>
void printfunc(int, int);
int main(void)
{
int dub1, dub2;
printf("Enter two decimal integers.\n");
scanf("%d %d", &dub1, &dub2);
printfunc(dub1, dub2);
printf("Cheerio for now.\n");
getchar();
getchar();
return 0;
}
void printfunc(int a, int b)
{
printf("%d %d\n", a, b);
}
Any guidance most gratefully received.
To clarify, I need to alter the function to be able to take two double arguments (e.g 1.2 and 56.3) and simply print them, i.e. void printfunc(double, double)