First, you need a main function in your code (c code):
Code:
#include <windows.h>
#include <stdio.h>
#include <time.h>
#ifndef WINDOWS
#include <sys/time.h>
#endif
int main(){
#ifdef WINDOWS
SYSTEMTIME beg;
#else
struct timeval beg;
struct tm *t;
#endif
#ifdef WINDOWS
GetLocalTime( &beg );
printf( "%02d:%02d:%02d:%06d\n", beg.wHour,
beg.wMinute, beg.wSecond, beg.wMilliseconds * 1000 );
#else
gettimeofday( &beg, NULL );
t = localtime( &beg.tv_sec );
printf( "%02d:%02d:%02d.%06d\n",
t->tm_hour, t->tm_min, t->tm_sec, (int) beg.tv_usec );
#endif
return 0;
}
Next, open the project properties (Alt+F7) in your Visual Studio and select "Configuration Properties>C/C++>Preprocessor" and add WINDOWS to the Preprocessor Definitions or, add directly in the code
Code:
#include <windows.h>
#include <stdio.h>
#include <time.h>
#define WINDOWS
...