Need to press enter for my console C++ code to continue executing on windows cmd

I have written a c++ code that sends logs to the console using cout. the issue is that i have sometimes to press enter so my code can continue executing and display next logs. for information, there is absolutely no input request in my code (cin or other).

I tried to use '\n' instead of endl. I also disabled inputs using this function:

FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));

but the issue still persists (the console still waits for me to press enter to continue executing the code...). Could you please help?

thanks in advance

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
    void switch_to_dealer() {
    HWND hWnd = CreateWindow(TEXT("C Windows"), TEXT("C Windows"), WS_OVERLAPPEDWINDOW,
        10, 10, 600, 480, NULL, NULL, NULL, NULL);
    int bbb = man->Dealer((MTAPI_NOTIFY_FUNC)DealingHandle, hWnd, NULL);
    if (bbb != RET_OK)
        cout << "Dealing switch error" << '\n';
    else
        cout << "Dealing mode connected" << '\n';
    while (1) {
        Sleep(100000000000);
    }
}

int main()
{
    FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));
    curl = curl_easy_init();
    if (curl) {
        string syurl = link;
        curl_easy_setopt(curl, CURLOPT_URL, syurl.c_str());
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
        cres = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
        cout << "Rates: " << readBuffer << '\n';

    }
    std::thread exchangerates(update_rates);
    std::thread dealer(switch_to_dealer);
    exchangerates.detach();
    dealer.detach();
    while (1) {
        std::this_thread::sleep_for(std::chrono::milliseconds(10000000000000));
    }
}
Last edited on
Show your code.
i updated the question with code
Topic archived. No new replies allowed.