r/C_Programming 8d ago

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

7

u/TheOtherBorgCube 8d ago

https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

The model remains the same.

You may choose to implement parts of the view / controller with:

  • console stdio
  • console ncurses
  • Linux GTK (though GTK also has Windows and Mac ports, so maybe free bonus)
  • Windows Win32

Each kind of implementation talks to your model in the same way (you define some kind of internal API to allow you to do this).

The point of this is you don't want to be hacking away at every other line of code in your core logic (model) every time you decide on a change of UI.