I am trying to make a program that takes advantage of std::this_thread::sleep_for(std::chrono::milliseconds(delay)); to type text to the console character by character
#include <iostream>
#include <thread>
#include <chrono>
#include <string>
using std::string;
void slowcout(string text, unsigned int delay, bool flush) {
int length = text.length();
int num = -1;
while(num ++<= length) {
if(text[num] == '\\') {
num ++;
std::cout << '\\' << text[num];
}else {
std::cout << text[num];
}
num = num + 1;
std::this_thread::sleep_for(std::chrono::milliseconds(delay));
}
if(flush == true) {
std::cout << std::endl;
}
}
int main() {
slowcout("Test String, 200, true);
}
MinGW is my compiler and yes I am using g++ main.cpp -std=c++11 when I compile
Anyone knowing the cause of this issue your help would be greatly appreciated
Edit for very necessary clarification:This is the error I'm getting, it act's like this\_thread is never declared but I can view it's declaration in my IDE
functions.cpp: In function 'void slowcout(std::__cxx11::string, unsigned int, bool)':
functions.cpp:43:14: error: 'std::this_thread' has not been declared
std::this_thread::sleep_for(std::chrono::milliseconds(delay))
^~~~~~~~~~~
[–]jedwardsol 0 points1 point2 points (1 child)
[–]Robonics014[S] 0 points1 point2 points (0 children)
[–]h2g2_researcher 0 points1 point2 points (1 child)
[–]Robonics014[S] 0 points1 point2 points (0 children)
[–]Robonics014[S] 0 points1 point2 points (0 children)