Here is another possible solution:
time_t stamp=time(NULL); struct tm* diferencia=localtime(&stamp); cout << diferencia->tm_hour*3600;
I think this is simpler, I tried the solution above and it did not work in VS2008.
PS: Sorry for my English.
EDIT: this will always output the same number, because it multiplies the number of hours - so if it is 2:00 AM it will always output 7200. Use instead:
time_t stamp=time(NULL); struct tm* diferencia=localtime(&stamp); cout << ((diferencia->tm_hour*3600)+(diferencia->tm_min*60)+(diferencia->tm_sec));
source share