Run C code in external window

已回答

Is it possible to run C-Code in an external window and not in the built in console?
Currently I'm manually running the .exe file after compiling to get it in an external window.
I prefer the external window because it works better for me.

0

@Michael there is no such option now. Why does external window work better in your case?

0
Avatar
Permanently deleted user

When I'm using the system("cls"); command it doesn't clear and it doesn't always print everything properly. For example it prints things into the wrong line or doesn't even print some lines.

0

@Michael, here is the feature request about the system("cls"): https://youtrack.jetbrains.com/issue/CPP-822. Feel free to comment or upvote.

Please try entering the following string of code before any printing (it disables buffering): 

setbuf(stdout, 0);

Does it help with printing out?



0
Avatar
Permanently deleted user

That string of code doesn't change anything

0

What toolchain do you use? Is it MinGW-w64?

0
Avatar
Permanently deleted user

I'm using MinGW Version 3.20

0

This issue in our tracker looks related: https://youtrack.jetbrains.com/issue/CPP-3787. Feel free to comment or upvote, follow it to get updates.

This problem most likely is MinGW-only. You can try to use Cygwin instead. If this is not possible, then try disabling PTY: go to Help | Find Action, type "Registry..." and in the list find and disable option "run.processes.with.pty". Disabling PTY helps to get the correct output in the Run console in some cases. Please note that, unfortunately, the run.processes.with.pty option is not saved after CLion's restart and should be disabled again every time you open CLion (if you need it to be disabled). We have the issue in our tracker about that: https://youtrack.jetbrains.com/issue/CPP-8395.

0
Avatar
Permanently deleted user

I finally found a workaround to launch it in an external window!

I created a file launch.bat in my "cmake-build-debug" folder and wrote the following lines:

 

@echo off
cls
<filename>.exe

 

Afterwards I created another file called start.bat in the same folder which hase the line:

start launch.bat

Then I made an External Tool in CLion which launches start.bat.

Then I had my program running in an external window!

0

请先登录再写评论。