1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- /*
- * cxxomfort example: chinese_zodiac
- *
- * See https://rosettacode.org/wiki/Chinese_zodiac
- *
- */
- #include <cxxomfort/base.hpp>
- #include <cxxomfort/string_view.hpp>
- #include <cxxomfort/ctime.hpp>
- #include <cxxomfort/array.hpp>
- #include <string>
- #include <iostream>
- void mysleep (unsigned);
- int main () {
- using namespace std;
- std::timespec ts;
- for (unsigned i=0; i < 10; ++i) {
- timespec_get(&ts, TIME_UTC);
- printf("%lu , %lu\n", ts.tv_sec, ts.tv_nsec);
- fflush(stdout);
- mysleep(500);
- }
- }
- #if defined(_POSIX_VERSION)
- #include <time.h>
- void mysleep (unsigned u) {
- usleep(u*1000);
- }
- #elif defined(_WIN32)
- // #include <windef.h>
- // #include <winbase.h>
- // #include <winsock2.h>
- #include <windows.h>
- void mysleep (unsigned u) {
- Sleep(u);
- }
- #endif
|