c++之sleep函数

时间:2022-10-19 14:32:44

c++之sleep函数

c++中使用sleep函数需要导入第三方库,标准库中没有该函数实现。

我们导入window.h使用Sleep()方法,注意:第一个S要大写,括号中的表示的整数倍的毫秒

Sleep(1000);表示休息一秒

 #include <iostream>
 #include <windows.h>
 #include <cstdlib>
 using namespace std;

 /**
 一个歌词显示作用  sunflower
 */
 int main()
 {

     system(cmd)

     cout << "Crash at my place, baby, you're a wreck" << endl;
     Sleep(2750);
     cout << "Thinkin' in a bad way, losin' your grip" << endl;
     Sleep(2660);
     cout << "Screamin' at my face, baby don't trip" << endl;
     Sleep(2620);
     cout << "Someone took a big L, don't know how that felt" << endl;
     Sleep(2660);
     cout << "Lookin' at you sideways, party on tilt" << endl;
     Sleep(2630);
     cout << "Ooh-ooh, some things you just can't refuse" << endl;
     Sleep(5150);
     cout << "She wanna ride me like a cruise" << endl;
     Sleep(2580);
     cout << "And I'm not tryna lose" << endl;
     Sleep(3890);
     cout << "And you're left in the dust" << endl;
     Sleep(2610);
     cout << "Unless I stuck by ya" << endl;

     ;
 }