Hi guys, uve been workin on a restaurant program and im tryin to write the time to the end of the receipt. so im writing information to a file. only problem is i cannot make my time function return the current time. I've tried everything. can you guys help??

im using:

char Time::currentTime()
{
  time_t rawtime;
  struct tm * timeinfo;

  time ( &rawtime );
  timeinfo = localtime ( &rawtime );
  return asctime (timeinfo);
}

and in the other class im usin to write the time:

list_of_orders <<time->currentTime()<<endl;

is this correct

Returning a pointer to char is different from returning a char.

You might want to try the function

gettimeoftheday()

PS I am not sure of the arguments

commented: Hey! Wow! This post is almost entirely useless! -2

You might want to try the function

gettimeoftheday()

PS I am not sure of the arguments

But changing the name of the function will just gimme the same result

Didn't you see the first reply to your post?

asctime returns a character pointer.

The currentTime function returns a character.

There is a mismatch here that needs to be fixed or taken into consideration.

ok guys ive been at this for a while now and vie got a new error:

int Create::createOrder(int room_no_food_order, int set_meal_choice, int side_order)
{
    char* get_time;
    get_time = time.printTime();
    .
    . 
    .
    .
    list_of_orders << "Time:"<<get_time<<endl;
}

and in my class to create the time i have:

char* CTime::printTime()
{
    time_t rawtime;
    char* str2;
    strcpy (str2,asctime( localtime( &currentTime)));
    return str2;
}

now i get the following compiler error pointing to the second line(get_time = time.printTime();)

the error is....

error: request for member `printTime' in `time', which is of non-class type `time_t ()(time_t*)'|

any ideas???? thanks to all who help...
_________________________________________________-
discussions like this is what keep the programming world go round!!!

time is a key word. So the compiler is not allowing you to call the print time function. Change the name of the object from time to time_1 and then try

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.