大佬教程收集整理的这篇文章主要介绍了在c中构建日期字符串,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我对c很新,所以我现在正在学习,但是我无法让它工作.以下是我的代码
time_t Now = time(null); struct tm *t = localtime(&Now); char currentDate[13]; char daY[3]; char month[3]; char year[5]; char hour[3]; char min[3]; sprintf(day,"%02d",t->tm_mday,sizeof(day)); sprintf(month,t->tm_mon+1,sizeof(month)); sprintf(year,"%04d",t->tm_year + 1900,sizeof(year)); sprintf(hour,t->tm_hour,sizeof(hour)); sprintf(min,t->tm_min,sizeof(min)); strcat(currentDate,day); strcat(currentDate,month); strcat(currentDate,year); strcat(currentDate,hour); strcat(currentDate,min); printf("Current Date: %s",currentDatE);
我究竟做错了什么.
以上是大佬教程为你收集整理的在c中构建日期字符串全部内容,希望文章能够帮你解决在c中构建日期字符串所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。