Code:
/* ***************************
*C Program Code::Blocks v1.0 *
*Written by: EvoTone *
*Date: Sept., 2006 *
**************************** */
#include <stdio.h>
typedef struct /*This structs DATE_RANGE w/ 3 constants num/num/char*/
{
const int lower; /*Defines a number as lower*/
const int upper; /*Defines a number as "upper"*/
const char * month; /*Defines month names*/
} DATE_RANGE; /*Name of the struct*/
static const DATE_RANGE date_range[]/*Defines struct as array,date_range[]*/
{
{ 0, 31, "January" }, /*Defines lower/upper/month variables in struct*/
{ 31, 59, "February" }, /*" "*/
{ 59, 91, "March" }, /*" "*/
{ 91, 121, "April" }, /*" "*/
{ 121, 152, "May" }, /*" "*/
{ 152, 182, "June" }, /*" "*/
{ 182, 213, "July" }, /*" "*/
{ 213, 244, "August" }, /*" "*/
{ 244, 274, "September" }, /*" "*/
{ 274, 305, "October" }, /*" "*/
{ 305, 335, "November" }, /*" "*/
{ 335, 365, "December" } /*" "*/
};
int main(void)
{
int i;
int julian; /*input value from user, needing conversion.*/
/*Intro. & Instructions*/
printf("This is a Julian to Calendar Date conversion program\n");
printf("you may input any Julian date and the corresponding\n");
printf("Calendar Date will be calculated for you\n\n");
/*Input Section*/
printf("Please enter the Julian date: (whole number format)\n");
scanf("%i", &julian);
printf("Well silly we know it's Year: 2006!\n\n");
/*Calculation Section*/
for (i = 0; i < (sizeof(date_range) / sizeof(date_range[0])); i++) /*Loop*/
{
if ((julian > date_range[i].lower) && (julian <= date_range[i].upper))
{
printf("And we know it's: %s\n", date_range[i].month);
break;
}
}
if( i == ( sizeof(date_range) / sizeof(date_range[0]) ) )
printf("Don't mess with me stupid!!...Julian Dates are only 1-365!\n");
return (0);
}
I think I'm getting what this is supposed to do but, there is syntax errors at line 15 and 48 that I can't figure out. I hadn't previously fooled with "struct" or setting an "array" in this manner so, even after reading up on it, I can't fix it. Little help please. I have added notes to places, telling the thought process I am taking in my attempt to explaining this.
~EvoTone~