Originally Posted by
AndiPersti
For a start you could look at the compiler warnings:
Code:
e$ make foo
cc -ggdb3 -Wall -Wextra foo.c -o foo
foo.c: In function ‘daycalc’:
foo.c:19:1: warning: statement with no effect [-Wunused-value]
foo.c:20:1: warning: statement with no effect [-Wunused-value]
foo.c:25:1: warning: statement with no effect [-Wunused-value]
foo.c:26:1: warning: statement with no effect [-Wunused-value]
foo.c:13:13: warning: unused variable ‘count’ [-Wunused-variable]
foo.c: At top level:
foo.c:36:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
foo.c: In function ‘main’:
foo.c:44:1: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
foo.c:44:1: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
foo.c:45:1: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
foo.c:45:1: warning: incompatible implicit declaration of built-in function ‘scanf’ [enabled by default]
foo.c:41:5: warning: variable ‘N1’ set but not used [-Wunused-but-set-variable]
foo.c:40:23: warning: unused variable ‘secondDay’ [-Wunused-variable]
Bye, Andreas
I accidentally posted it with a typo. Here's the one that should work. Thanks.
Code:
#include <stdio.h>
struct date {
int month;
int day;
int year;
};
struct date daycalc (struct date entry){
if(entry.month <=2){
entry.year-1;
entry.month + 13;
}
else{
entry.year ;
entry.month+1;
}
return entry;
}
void main (){
struct date daycalc (struct date entry);
struct date firstDay, secondDay, T1;
int N1;
printf("Please enter mm/dd/yyyy: ");
scanf("%i%i%i", &firstDay.month, &firstDay.day, &firstDay.year);
T1=daycalc(firstDay);
N1=( 1461 * T1.year ) / 4 + ( 153 * T1.month ) / 5 + T1.day;
//printf("%i", N1);
printf("%i", T1.year);
}
Nevermind I see what you mean. My compiler doesn't have any of those warnings.
Ok, I see how you got those warnings. Aw this makes sense. Anyway thanks once again.