help problem incasting pointer in c language

float secToHours(long time,float* hours,float* minutes,float* seconds);


int main(){
long time;
float seconds=0;
float minutes=0;
float hours=0;
float* phours=&hours;
float* pminutes=&minutes;
float* pseconds=&seconds;
void* pVoid;
float* pMin;
printf("Please enter your time in second(s):");
scanf("%d",&time);


secToHours(time,&hours,&minutes,&seconds);
pVoid=phours;
printf("hours=%f",*phours);//here answer is 0.000(help to solve)
pMin=pminutes;
printf("minutes=%f",*pMin);// but here why 0.000(help to solve)
pVoid=pseconds;
printf("secomds=%f",*(float*)pVoid);//here why answer can be 3

system("pause");
return 0;
}

float secToHours(long time,float* hours,float* minutes,float* seconds)
{
long localTime;

localTime=time;
*seconds=localTime%60;
//localTime=localTime/60;
*minutes=localTime/60;
*hours=localTime/60;

return ;
}


help me to solve the hours and minutes could not produce the accurate answer

Thank you
Last edited on
Seconds = ( TotalSeconds / 60 ) % 60
Topic archived. No new replies allowed.