c语言全局变量未定义,有没有大佬帮看下为什么报错 定义了结构体全局变量 会报未定义错...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

#include

#define START_YEAR 1970;

typedef struct

{

int year;

char month;

char day;

char hour;

char minute;

long second;

}kalendartypedef;

long write_data(int year,char month,char day,char hour,char minute,long second);

long kalendar(kalendartypedef*kalendarstruct);

struct kalendartypedef processclock_data(long clockdata);

void printf_clock_NOW(kalendartypedef * kalendarstruct);

int main()

{

int a,b,c,d,e;

long f;

while(1){

scanf("%d%d%d%d%d%ld",&a,&b,&c,&d,&e,&f);

//(processclock_data(write_data(a,b,c,d,e,f)))

kalendartypedef sendcolckdata=processclock_data(write_data(a,b,c,d,e,f));

printf_clock_NOW(&sendcolckdata);

//printf("%ld\n",processclock_data(write_data(a,b,c,d,e,f))))

//printf("%ld\n",write_data(a,b,c,d,e,f))

system("pause");

return 0;

}

long write_data(int a,char b,char c,char d,char e,long f)

{

long num;

kalendartypedef kalendarstructure;

kalendarstructure.year=a;

kalendarstructure.month=b;

kalendarstructure.day=c;

kalendarstructure.hour=d;

kalendarstructure.minute=e;

kalendarstructure.second=f;

num=kalendar(&kalendarstructure);

return num;

}

long kalendar(kalendartypedef*kalendarstruct) //24小时制

{

char leapyear=0;//闰

char commonyear=0;//平

int temp=START_YEAR;

for(temp;tempyear;temp++)

{

if((temp%4==0&&temp%100!=0)||temp%400==0)leapyear++;

else commonyear++;

}

//printf("1970-2017有: %d个平年%d个闰年\n",commonyear,leapyear);

long tolsec=leapyear*366*24*60*60+commonyear*365*24*60*60;

//printf("总共有: %ld秒\n",tolsec);

if(kalendarstruct->year%4==0&&kalendarstruct->year%100!=0&&kalendarstruct->year%400==0)leapyear=1;

else leapyear=0;

//printf("2018年是: %ld年1是闰年\n",leapyear);

if(commonyear)

{

int tempday=0;

for(temp=kalendarstruct->month-1;temp>0;temp--)

{

switch(temp)

{

case 1: tempday+=31;break;

case 2: if(leapyear==0)tempday+=28;

else tempday+=29;break;

case 3: tempday+=31;break;

case 4: tempday+=30;break;

case 5: tempday+=31;break;

case 6: tempday+=30;break;

case 7: tempday+=31;break;

case 8: tempday+=31;break;

case 9: tempday+=30;break;

case 10: tempday+=31;break;

case 11: tempday+=30;break;

}

}

//printf("2018截止12月27日共: %ld天\n",tempday);

tempday+=kalendarstruct->day-1;

//printf("2018截止12月27日共: %ld天\n",tempday);

tolsec+=tempday*24*60*60;

tolsec+=kalendarstruct->second+kalendarstruct->minute*60+kalendarstruct->hour*60*60;

}

return tolsec;

}

kalendartypedef processclock_data(long clockdata)

{

kalendartypedef clockdata_structure;

long today_sec_tol=clockdata%8640;

int tol_day=clockdata/8640;

int start_year=START_YEAR;

//clockdata-=today_sec_tol;

char temp1=0,temp2=0;

while(tol_day>365)

{

start_year++;

if((start_year%4==0&&start_year%100!=0)||start_year%400==0){tol_day-=366;temp1++;}

else {tol_day-=365;temp2++;}

}

tol_day-=(temp1*366+temp2*365);

switch(1)

{

case 1:if(tol_day>31)tol_day-=31;else {clockdata_structure.month=1;clockdata_structure.day=tol_day;break;}

case 2:if((start_year%4==0&&start_year%100!=0)||start_year%400==0)

{

if(tol_day>29)tol_day-=29;

else {clockdata_structure.month=2;clockdata_structure.day=tol_day;break;}

}

else if(tol_day>28)tol_day-=28;

else {clockdata_structure.month=2;clockdata_structure.day=tol_day;break;}

case 3:if(tol_day>31)tol_day-=31;else {clockdata_structure.month=3;clockdata_structure.day=tol_day;break;}

case 4:if(tol_day>30)tol_day-=30;else {clockdata_structure.month=4;clockdata_structure.day=tol_day;break;}

case 5:if(tol_day>31)tol_day-=31;else {clockdata_structure.month=5;clockdata_structure.day=tol_day;break;}

case 6:if(tol_day>30)tol_day-=30;else {clockdata_structure.month=6;clockdata_structure.day=tol_day;break;}

case 7:if(tol_day>31)tol_day-=31;else {clockdata_structure.month=7;clockdata_structure.day=tol_day;break;}

case 8:if(tol_day>31)tol_day-=31;else {clockdata_structure.month=8;clockdata_structure.day=tol_day;break;}

case 9:if(tol_day>30)tol_day-=30;else {clockdata_structure.month=9;clockdata_structure.day=tol_day;break;}

case 10:if(tol_day>31)tol_day-=31;else {clockdata_structure.month=10;clockdata_structure.day=tol_day;break;}

case 11:if(tol_day>30)tol_day-=30;else {clockdata_structure.month=11;clockdata_structure.day=tol_day;break;}

case 12:if(tol_day>31)tol_day-=31;else {clockdata_structure.month=12;clockdata_structure.day=tol_day;break;}

}

clockdata_structure.hour=today_sec_tol/3600;

clockdata_structure.minute=today_sec_tol%3600/60;

clockdata_structure.second=today_sec_tol%3600%60;

clockdata_structure.year=start_year;

return clockdata_structure;

}

void printf_clock_NOW(kalendartypedef * kalendarstruct)

{

printf("现在是%d年",kalendarstruct->year);

printf("%d月",kalendarstruct->month);

printf("%d日",kalendarstruct->day);

printf("%d点",kalendarstruct->hour);

printf("%d分",kalendarstruct->minute);

printf("%ld秒",kalendarstruct->second);

}

  • 0
    点赞
  • 0
    收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:深蓝海洋 设计师:CSDN官方博客 返回首页
评论
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值