Board index » delphi » int Hour

int Hour

Hi Everyone, Greetings,
Is it permitted to use int Hour as:

char int pRes[3];
int Hour;
sprintf(pRes, "%g", Hour);
CurrentTime->SetWindowText(pRes);   // ***
Which file contains the class in which Hour resides?
Thanx, Pete
Pete Aldridge
pe...@peoplepc.com

 

Re:int Hour


Quote
Pete Aldridge wrote:
> Is it permitted to use int Hour as:

> char int pRes[3];
> int Hour;
> sprintf(pRes, "%g", Hour);
> CurrentTime->SetWindowText(pRes);   // ***
> Which file contains the class in which Hour resides?

Please post (approximately) correct code. What problem are you trying to
solve?

Re:int Hour


Sorry, Thomas, Thank you!
I'm using BC++5.02.

float get_number(TEdit *calc)
{
 float ans = 0;
 char*       pStr;
 int         nSize;

 if (calc)
 {
   pStr = new char[nSize = calc->GetWindowTextLength() + 1];
     if (pStr)
     {
       calc->GetWindowText(pStr, nSize);
       ans = atof(pStr);
       delete pStr;
     }
 }
 return ans;

Quote
}

void TTimeDialog::CmCalcTime() {
  TTimeTransfer  TimeTransfer;
  double a, b, c = 0;
  a = get_number(PercentDone);
  b = get_number(CpuTimeElapsed);
  c = (b * 100) / a;

  char pRes0[255];
  sprintf(pRes0, "%g", c);
  TotalTime->SetWindowText(pRes0);
...

I need a system date, local;  for simplicity, only Hour and Minute. Under
TimeStamp,
int Hour and int Minute are defined. My prob, how do I set up these
variables such
that each may be added to?  Eg, TotalTime is a TEdit char ptr. c is a
numeric value as 51.671 Hours
Is it possible to use int Hour to which c / 24 could be added, ie, local
Hour + c/24 without
having to use the entire struct?

Additionally,
sprintf(pRes2, "%g", asctime(area));
CurrentTime->SetWindowText(pRes2);  // where asctime(area) is a string.

Thank you,
Pete Aldridge  pe...@peoplepc.com

Re:int Hour


Quote
Pete Aldridge wrote:

>    pStr = new char[nSize = calc->GetWindowTextLength() + 1];
>      if (pStr)
>      {
>        calc->GetWindowText(pStr, nSize);
>        ans = atof(pStr);
>        delete pStr;

This needs to be

delete [] pStr;

Quote
> Additionally,
> sprintf(pRes2, "%g", asctime(area));

%g seems to be the wrong format specifier.

Apart from that, I have absolutely no idea what you are asking for.

Other Threads