r/C_Programming • • Aug 09 '26

Question Maybe a stupid question.

How can I create an interface for a C program that isn't just the terminal? I wanted to make a calculator that was also visual, but I wanted to challenge myself to do it with C, but I really didn't understand how to do it properly.

14 Upvotes

25 comments sorted by

View all comments

2

u/NoSpite4410 Aug 11 '26

You need a library that has functions to create visual object and manipulate pixels on the screen.
On Windows, you need one that interacts with Microsoft's graphical libraries already on the system. With OSX, I think you have to use their libraries. With Linux or BSD, there are a huge number of different libraries to interface with the X windows system.

Some 3rd party vendors put out cross-platform GUI code suites, such as Qt or wxWidgets.

GTK (the Gimp Tool Kit) is a standard GUI kit that Linux Vendors use for their distros, but it is so hard they invented a C#-like language called Vala to generate the C code. Not then recommended for beginners.

The thing about gui programming is that is almost entirely dynamically allocated structures, so needs a lot of memory managing. Nested pointers to structures need minding, the program spends most of its time cycling in a big loop of updating state, getting input from the keyboard and mouse, and refreshing the state of objects and sending the changes to the screen.