It's pretty simple really. Let me condense it a little for you:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
float response, choice;
int playerInput()
{
return 1;
}
int computerChoice()
{
return 2;
}
void displayWinner()
{
printf("%f:%f\n", response,choice);
}
int main(void)
{
int pinput, cinput;
pinput = playerInput();
cinput = computerChoice();
displayWinner();
return 0;
}
When you run that, you will get:
0.000000:0.000000
Can you see why?
Where in that code do you set the values of
response
and
choice
?
You don't. You save the values that the two functions return in
local variables but you use
global variables to decide the result in
displayResult
What you should be doing is storing them in local variables, and then passing those values to the
displayResult
function as parameters:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int playerInput()
{
return 1;
}
int computerChoice()
{
return 2;
}
void displayWinner( int player, int computer)
{
printf("%u:%u\n", player, computer);
}
int main(void)
{
int pinput, cinput;
pinput = playerInput();
cinput = computerChoice();
displayWinner(pinput, cinput);
return 0;
}
Now you get the results you expect:
1:2
You need to do something very similar in your code.
Oh, and do yourself a favour: indent your code. It's a lot easier to see where functions, loops, conditions, and so on start and end when you indent it!