【文件属性】:
文件名称:linux下中文显示日期
文件大小:1KB
文件格式:C
更新时间:2018-06-20 07:39:10
linux c
#include
#include
int main(int argc,char **argv)
{
time_t timep;
struct tm *p;
char array[10][4]={"零","一","二","三","四","五","六","七","八","九"};
char name[6][4]={"年","月","日","点","分","秒"};
int flag;
int i,j,k;
i=0;
k=0;
j=1000;
time(&timep);
p=localtime(&timep);
printf("%d-%d-%d %d:%d:%d\n",1900+p->tm_year,p->tm_mon,p->tm_mday,p->tm_hour,p->tm_min,p->tm_sec);
int time[6]={1900+p->tm_year,p->tm_mon,p->tm_mday,p->tm_hour,p->tm_min,p->tm_sec};
while(i<6)
{
flag =time[i];
if(flag==0)printf("%s",array[0]);
else
while(j>0)
{
if(flag>=j)
{
while(j)
{
if(j==1000)k=1;
if(k==0)
{
if(((j==10&&(flag/j)!=1))||((j==1)&&((flag/j)!=0)))printf("%s",array[flag/j]);
if(j==10)printf("十");
}
else printf("%s",array[flag/j]);
j/=10;
}
}
j/=10;
}
printf("%s",name[i]);
i++;
k=0;
j=1000;
}
printf("\n");
return 0;
}