TheX
13/12/2006, 16:22
#include <stdio.h>
struct time {
int hour, minutes, seconds;
};
void updateTime( struct time );
void updateTime( struct time t1 )
{
t1.seconds=t1.seconds+45;
if( t1.seconds == 60) {
t1.seconds = 0;
++t1.minutes;
if(t1.minutes == 60) {
t1.minutes = 0;
++t1.hour;
if(t1.hour == 24)
t1.hour = 0;
}
}
return ;
}
void main()
{
struct time uT;
printf("Enter the time (hh:mm:ss):\n");
scanf("%d:%d:%d", &uT.hour,&uT.minutes,&uT.seconds);
updateTime(uT);
printf("The new time is %02d:%02d:%02d\n",uT.hour,uT.minutes,uT.seconds);
return ;
}
Saniyeyi 45 artırmak ve yeni saati yazmak istiyorum.Bu kodda ne gibi bi hata var.Fonksiyonu doğru yazdığıma inanıyorum.Ama yine aynı saati veriyor.
Yardım Lütfen...
struct time {
int hour, minutes, seconds;
};
void updateTime( struct time );
void updateTime( struct time t1 )
{
t1.seconds=t1.seconds+45;
if( t1.seconds == 60) {
t1.seconds = 0;
++t1.minutes;
if(t1.minutes == 60) {
t1.minutes = 0;
++t1.hour;
if(t1.hour == 24)
t1.hour = 0;
}
}
return ;
}
void main()
{
struct time uT;
printf("Enter the time (hh:mm:ss):\n");
scanf("%d:%d:%d", &uT.hour,&uT.minutes,&uT.seconds);
updateTime(uT);
printf("The new time is %02d:%02d:%02d\n",uT.hour,uT.minutes,uT.seconds);
return ;
}
Saniyeyi 45 artırmak ve yeni saati yazmak istiyorum.Bu kodda ne gibi bi hata var.Fonksiyonu doğru yazdığıma inanıyorum.Ama yine aynı saati veriyor.
Yardım Lütfen...