Here is what i have so far:
EDIT to add in the code to check the size
bool MyTime::setTime(char timearray[])
{
int size = sizeof(timearray)/sizeof(*timearray);
cout << size << " " << timearray[1] << " " << timearray[2] << " ";
switch(size)
{
case 5:
timearray[3] = toupper(timearray[3]);
timearray[4] = toupper(timearray[4]);
if(timearray[1] == ':')
{
if((timearray[3] == 'A' || timearray[3] == 'P') && timearray[4] == 'M')
{
if(timearray[0] > 0 && timearray[0] <= 12 && timearray[2] >= 0 && timearray[2] < 60)
{
iHour = timearray[0];
iMinutes = timearray[2];
if (timearray[3] == 'P' && iHour != 12)
{
iHour += 12;
}
if (timearray[3] == 'A' && iHour == 12)
{
iHour = 0;
}
cout << iHour << timearray[1] << iMinutes << AMPM[0] << AMPM[1] << " ";
return true;
}
else
{
iHour = 0;
iMinutes = 0;
timearray[3] = 'E';
timearray[4] = 'R';
cout << "HAHA " << iHour << iMinutes << AMPM[0] << AMPM[1] << " ";
return false;
}
}
else
{
iHour = 0;
iMinutes = 0;
timearray[3] = 'E';
timearray[4] = 'R';
cout << "HAHA " << iHour << iMinutes << AMPM[0] << AMPM[1] << " ";
return false;
}
}
break;
case 7:
return true;
break;
}
}
I was wondering If i use Sizeof(timearray)/Sizeof(*timearray) will that produce an accurate count of the size of the array if the paramiter passed to setTime was a pointer to an array?
I.E.
//will this work? if i use the Sizeof(timearray)/Sizeof(*timearray) to find the size of the array?
char time[5] = {12, ":" , 45, "A", "M"};
MyTime t;
t.SetTime(time);
This post has been edited by rgfirefly24: 09 November 2008 - 08:52 AM

New Topic/Question
Reply





MultiQuote




|