0

what I'm trying to do is see if a year is bissextile or not, but when I'm using a boolean function it gives me this strange message.

here is my code:

#include<stdio.h>
#include<stdbool.h>

main(){
    int n1;
    printf("what is the year?\n");
    scanf("%d",&n1);

    if(itIS(n1)){
        printf("the year %d is bissextile\n",n1);
    }else{
        printf("the year %d is not bissextile\n",n1);
    }
}

bool itIS(int n1){
    bool is = false;
    if((n1/400)== 0){
        is = true;
    }
    return is;
}

and this is the thing that appears to me:

  exe1.c:144:6: error: conflicting types for ‘itIS’ bool itIS(int n1){
  ^
  exe1.c:134:6: note: previous implicit declaration of ‘itIS’ was here if(itIS(n1)==true){
  ^

I don't understand what's the problem. Although if I do this without the boolean function it works perfectly.

Edit: So i already know what's the problem thanks to @Bill Lynch. The problem is i need to write the boolean function before the main function, so the compiler sees the function, basically that's it.

bluewolfxD
  • 69
  • 1
  • 7
  • 1
    the main function is written as 'int main(void)' or 'int main( int argc, char **argv ). enable all warnings when compiling, then your compiler would have told you about this problem (and about the missing return value; statement at the end of main() – user3629249 Mar 20 '15 at 01:26
  • the code is missing, before main() a prototype for function: 'bool itIS( int );' – user3629249 Mar 20 '15 at 01:29
  • @user3629249 even when adding 'int main(void)' it gives the same warning :S – bluewolfxD Mar 20 '15 at 01:39

1 Answers1

3

You didn't declare the function before using it. Add this before main:

 bool itIS(int n1);

Also, it's int main(void), not main()

Yu Hao
  • 119,891
  • 44
  • 235
  • 294