Console Program in C++ -


this question has answer here:

i messing around c++ console programming. wondering if there way make text appear on console specific amount of time, go more text. essentially, i'm trying create timer object. or if you're familiar python, like

import timer  print "hello world" timer.sleep(2) print "hello again world" timer.sleep(2) 

if me this, appreciate it, in advance.

there's no built-in c++ functionality this, have resort platform-specific functions.

on posix systems (linux, mac os x, bsd, ...) can use sleep <unistd.h> (for delay second resolution) or nanosleep <time.h> (nominal resolution of nanoseconds, worse in practice). on windows, instead, can use sleep api <windows.h> (nominal resolution of milliseconds).

---edit---

as specified in comments, in c++11 there's std::this_thread::sleep_for.


Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

java - Jtable duplicate Rows -

java - Run a .jar on Heroku -