我试着逐行调试代码,发现它在“if (strcmp(takein.year, takein.year2) == 0)”这一行显示了错误。
Error Image - click here
请检查上面的链接。我用红色框标记了这条线。不知道为什么会出现该错误。
#include<stdio.h>
#include<stdlib.h>
#include<process.h>
//STRUCTURE
struct date_struct
{
int day;
int month;
int year;
int day2;
int month2;
int year2;
};
//USER-DEFINED FUNCTION
float input(struct date_struct takein);
char tarik(struct date_struct printer);
void header();
//STRUCTURE-VARIABLES
struct date_struct date = { 0,0,0 };
void header()
{
printf("*-*-*-*DATE_STRUCT*-*-*-*");
printf("\n\n");
}
//PROGRAM STARTS HERE
main()
{
//HEADING
header();
//FUCNTION CALL-OUT
input(date);
//TERMINAL_PAUSE
system("pause");
}
float input(struct date_struct takein)
{
printf("Enter the Date(1) : \n");
printf("Day : ");
scanf_s("%d", &takein.day);
printf("\n");
printf("Month : ");
scanf_s("%d", &takein.month);
printf("\n");
printf("Year : ");
scanf_s("%d", &takein.year);
printf("\n");
printf("\n");
printf("Enter the Date-(2) : \n");
printf("Day : ");
scanf_s("%d", &takein.day2);
printf("\n");
printf("Month : ");
scanf_s("%d", &takein.month2);
printf("\n");
printf("Year : ");
scanf_s("%d", &takein.year2);
printf("\n");
tarik(takein);
if (strcmp(takein.year, takein.year2) == 0)
{
if (strcmp(takein.month, takein.month2) == 0)
{
if (strcmp(takein.year, takein.year2) == 0)
{
return(0);
}
else
return(1);
}
else
return(1);
}
else
return(1);
}
char tarik(struct date_struct printer)
{
switch (printer.month)
{
case 1:
printf("Date(1) : January %d, %d\n\n", printer.day, printer.year);
break;
case 2:
printf("Date(1) : February %d, %d\n\n", printer.day, printer.year);
break;
case 3:
printf("Date(1) : March %d, %d\n\n", printer.day, printer.year);
break;
case 4:
printf("Date(1) : April %d, %d\n\n", printer.day, printer.year);
break;
case 5:
printf("Date(1) : May %d, %d\n\n", printer.day, printer.year);
break;
case 6:
printf("Date(1) : June %d, %d\n\n", printer.day, printer.year);
break;
case 7:
printf("Date(1) : July %d, %d\n\n", printer.day, printer.year);
break;
case 8:
printf("Date(1) : August %d, %d\n\n", printer.day, printer.year);
break;
case 9:
printf("Date(1) : September %d, %d\n\n", printer.day, printer.year);
break;
case 10:
printf("Date(1) : Octomber %d, %d\n\n", printer.day, printer.year);
break;
case 11:
printf("Date(1) : November %d, %d\n\n", printer.day, printer.year);
break;
case 12:
printf("Date(1) : Devember %d, %d\n\n", printer.day, printer.year);
break;
}
switch (printer.month2)
{
case 1:
printf("Date(2) : January %d, %d\n\n", printer.day2, printer.year2);
break;
case 2:
printf("Date(2) : February %d, %d\n\n", printer.day2, printer.year2);
break;
case 3:
printf("Date(2) : March %d, %d\n\n", printer.day2, printer.year2);
break;
case 4:
printf("Date(2) : April %d, %d\n\n", printer.day2, printer.year2);
break;
case 5:
printf("Date(2) : May %d, %d\n\n", printer.day2, printer.year2);
break;
case 6:
printf("Date(2) : June %d, %d\n\n", printer.day2, printer.year2);
break;
case 7:
printf("Date(2) : July %d, %d\n\n", printer.day2, printer.year2);
break;
case 8:
printf("Date(2) : August %d, %d\n\n", printer.day2, printer.year2);
break;
case 9:
printf("Date(2) : September %d, %d\n\n", printer.day2, printer.year2);
break;
case 10:
printf("Date(2) : Octomber %d, %d\n\n", printer.day2, printer.year2);
break;
case 11:
printf("Date(2) : November %d, %d\n\n", printer.day2, printer.year2);
break;
case 12:
printf("Date(2) : Devember %d, %d\n\n", printer.day2, printer.year2);
break;
}
return;
}
我是一名优秀的程序员,十分优秀!