craig_phillips2
Apr 14th, 2002, 04:45 PM
how can i get the current month and year as int values using C programming methods as opposed to C++.
I cant use C++ because it is for a procedural programming assignment, not OO. I want to write them to my struct:
struct temp_rec
{
int iYear;
int iMonth;
int iTemp;
int iLoc;
char* sLoc;
};
temp_rec trRec;
void get_temp()
{
temp_rec* pRec = &trRec;
char sVal[20];
int iVal = 0;
do{
clrscr();
printf("Please enter the location: ");
gets(sVal);
pRec->sLoc = sVal;
if((iVal = get_loc_id(sVal)) == 0)
{
printf("Department ID not found!");
do{
printf("\nPlease enter Department ID: ");
gets(sVal);
iVal = atoi(sVal);
printf("Debug iVal = %d",iVal);
getch();
}while((!chk_dept(iVal)) || iVal < 1)
}
pRec->iLoc = iVal;
pRec->iYear = // The current year
pRec->iMonth = // The current month
printf("Please enter temperature: ");
gets(sVal);
iVal = atoi(sVal);
printf("Debug iVal = %d",iVal);
getch();
printf("\n\nYou are about to add the following details:\n"
"\nDepartment ID: %d"
"\nDepartment Name: %s"
"\nTemperature: %d"
"\n\nTo be added for %s %d."
"\n\nIs this information correct? ",
pRec->iLoc,pRec->sLoc,pRec->iTemp,get_month(pRec->iMonth), pRec->iYear);
gets(sVal);
}while(!UCase(sVal[0]) == 'Y');
}
I cant use C++ because it is for a procedural programming assignment, not OO. I want to write them to my struct:
struct temp_rec
{
int iYear;
int iMonth;
int iTemp;
int iLoc;
char* sLoc;
};
temp_rec trRec;
void get_temp()
{
temp_rec* pRec = &trRec;
char sVal[20];
int iVal = 0;
do{
clrscr();
printf("Please enter the location: ");
gets(sVal);
pRec->sLoc = sVal;
if((iVal = get_loc_id(sVal)) == 0)
{
printf("Department ID not found!");
do{
printf("\nPlease enter Department ID: ");
gets(sVal);
iVal = atoi(sVal);
printf("Debug iVal = %d",iVal);
getch();
}while((!chk_dept(iVal)) || iVal < 1)
}
pRec->iLoc = iVal;
pRec->iYear = // The current year
pRec->iMonth = // The current month
printf("Please enter temperature: ");
gets(sVal);
iVal = atoi(sVal);
printf("Debug iVal = %d",iVal);
getch();
printf("\n\nYou are about to add the following details:\n"
"\nDepartment ID: %d"
"\nDepartment Name: %s"
"\nTemperature: %d"
"\n\nTo be added for %s %d."
"\n\nIs this information correct? ",
pRec->iLoc,pRec->sLoc,pRec->iTemp,get_month(pRec->iMonth), pRec->iYear);
gets(sVal);
}while(!UCase(sVal[0]) == 'Y');
}