Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CLion won't show output in Debug

Tags:

c

debugging

clion

When I start up the program, this is the output:

-------------------- HASHMAP MANAGEMENT BOOT MENU -------------------------
Would you like to:
(a) create a new hashmap
(b) load an existing one
(q) exit
>

However, when debugging, none of this shows up. Checking the debug, it does go over the printf() commands, but it just refuses to let them show up in the console. Input registers, but output never comes.

int main(void){
    bool on = true;
    char choice = ' ';
    int status = 0;
    while(on){
        if(status == -1){
            printf("\n[ERROR] : HASHMAP NOT INITIALISED\n");
        }
        printf("\n-------------------- HASHMAP MANAGEMENT BOOT MENU -------------------------\n");
        printf("Would you like to:\n(a) create a new hashmap\n(b) load an existing one\n(q) exit\n> ");

        scanf("%c",&choice);
        ...
        ...
    }
}

This is how the start of the code is, excluding all the #includes. Also, for some reason, CLion says the code I'm building is task2-a.c | Debug if that's any help. task2-a.c being the name of the C file that's being built. I dunno what's going on...

Update: Debugging works great on Ubuntu 17.04 Clion 2017.2. It just doesn't work on Windows 10 CLion 2017.3.

like image 987
ENBYSS Avatar asked Dec 12 '17 15:12

ENBYSS


1 Answers

Putting setbuf(stdout, 0); before any printf statement or any output happens fixed this problem.

like image 184
ENBYSS Avatar answered Sep 18 '22 06:09

ENBYSS