Determine specific size for console in C

Asked

Viewed 606 times

5

It is possible to set a specific size for the codeblock console (In C language) to open when I run the program?

I need it to open at a certain size because I won’t use the whole screen.

I saw there’s a way to do it in the library windows.h but I wanted to Ubuntu and I’m not finding.

NOTE: Codeblock is the editor I am using to program in C in Ubuntu

2 answers

3


The command line codeblocks uses to activate the console can be changed in Settings -> Environment -> General Settings.

In linux the default is:

xterm -T $TITLE -e

You can change the xterm command line by changing the window size. Take a look at the -Geometry parameter in the xterm documentation.

  • Thank you, I’ll read the documentation and see if that’s what I need. ;)

2

The command gnome-terminal --geometry=20x20 -e ./meuprograma opens a 20x20 Gnome terminal window (measured in characters) already running the program meuprograma located in the current directory.

You can make a script file that runs this command (i.e., a .sh file with this command inside and marked as executable) and distribute it in the same folder as the binary. This will give the effect you want. As for Code::Blocks, I can’t tell what he does or how he does it, but that’s irrelevant because he’s just the IDE and has no relation to the final program.

  • 1

    In the problem in question the IDE is related since the console is opened by it to run the Debugger; I already used gnome-terminal with codeblocks but, for some strange reason, the operation became erratic which ends up generating headaches when debugging. With xterm, although gdb gives a terminal error at the beginning it works perfect.

  • I assumed that the AP didn’t want an application to be run inside an IDE every time because I don’t see the point in it.

  • Thanks, I’ll read about it and try to understand better how it works. ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.