睡觉(4000)显示。每1000(C ++)

时间:2014-10-27 22:37:32

标签: c++

注意我是初学者。

我要做的是显示一个"。"在计时器中每1000秒。我想要"。"在cout后面显示。

#include <iostream>
#include <windows.h>


using namespace std;

int main()

{

    char uname;
    char pword;

    cout << "Initializing EKG";
    Sleep(4000);
      /* while/for Sleep(1000) cout << "."
         while Sleep(1000*2) cout << "."
      */
     //Something along those lines I am trying to achieve. 
     //Can't I use a ++ or something similar to increase the . to .. to ... to ....? 

    return 0;

}

1 个答案:

答案 0 :(得分:5)

您可以使用简单的for循环来执行此操作。

for(int i = 0; i < 4; i++){
      Sleep(1000);
      cout << ".";
}