I've just started to learn C, and right now I find it a bit confusing how to call one function from another. Here's my little project, I thought that writhing the line "int result = timeToWork;" would be enough to call that function, but the warning "initialization of 'int' from 'int(*)(int)' makes integer from pointer without a cast" appears. The project compiles, but the result is some weird numbers instead of printing the line. What am I doing wrong?
#include<stdio.h>
int timeToWork(int input);
int main()
{
printf("Please, enter the number \n");
int key = 0;
fflush(stdout);
scanf("%d", &key);
int result = timeToWork;
printf("Time = %d \n",timeToWork);
return 0;
}
int timeToWork(int input)
{
if(input == 1)printf("It will take you 25 minutes to get to your destination by car \n");
else if(input == 2)printf("It will take you 20 minutes to get to your destination by bike \n");
else if(input == 3)printf("It will take you 35 minutes to get to your destination by bus \n");
else if(input == 4)printf("It will take you 30 minutes to get to your destination by train \n");
else printf("ERROR: please, enter a number from 1 to 4 \n");
return 0;
}