warning: control reaches end of non-void function [-Wreturn-type]

前端 未结 2 1258
说谎
说谎 2020-12-13 07:16

I am having a slight is regarding functions. I believe it is likely because I am not using them. My code is as follows:

/*date difference calculator*/

#incl         


        
相关标签:
2条回答
  • 2020-12-13 07:56

    You just need to return from the main function at some point. The error message says that the function is defined to return a value but you are not returning anything.

      /* .... */
      if (Date1 == Date2)  
         fprintf (stderr , "Indicating that the first date is equal to second date.\n"); 
    
      return 0;
    }
    
    0 讨论(0)
  • 2020-12-13 08:14

    You can also use EXIT_SUCCESS instead of return 0;. The macro EXIT_SUCCESS is actually defined as zero, but makes your program more readable.

    0 讨论(0)
提交回复
热议问题