我正在为一套月租和年租的公寓设计付款系统。我已经使用了<stdio.h>和<time.h>,但我不能附加实际时间和支付房租之间的条件。我已经编写了以下代码。
case 'y' :
printf("Annually Rental: $29.99/year\n");
rent = 29.99;
utility = utilities_bill();
printf("Your payment this month is $%.2f\n",(rent+utility));
break;这显然位于switch函数内部。如何设置代码连接实际日期、时间和房租?例如,这个月是4月份,所以每年租房的客户只需支付水电费。但如果是在1月份,他们必须同时支付房租和水电费。我可以执行if函数吗?我必须使用struct tm吗?我现在已经迷路了。
发布于 2020-04-03 00:28:18
可能有用的项目是struct *tm和一些time functions……这里有一个简单的例子。
int main ()
{
time_t rawtime;
struct tm * timeinfo;
time (&rawtime);
timeinfo = localtime (&rawtime);
printf ("Current local time and date: %s", asctime(timeinfo));
return 0;
}Read more here
https://stackoverflow.com/questions/60995893
复制相似问题