Just learned that there is no pre-defined graphics library for C. I want to get the resolution of the current monitor screen.
Asked
Active
Viewed 659 times
0
-
2Then you need to look up how it's done on your platform/OS – StoryTeller - Unslander Monica Mar 30 '17 at 12:47
-
1For Linux, see for example here: http://stackoverflow.com/questions/1829706/how-to-query-x11-display-resolution. – Hellmar Becker Mar 30 '17 at 12:49
-
You can use a cross-platform library for this, e.g. [SDL](https://www.libsdl.org) or [GLFW](http://www.glfw.org). – Emil Laine Mar 30 '17 at 12:49
-
3Are you looking for the size of the whole display or the current terminal? On a system with two monitors, which monitor are you looking for? Are you looking for the size in pixels or characters or something else? – Jonathan Leffler Mar 30 '17 at 12:50
-
Then you'll have to pick a graphics library (such as OpenGL or a native API) and use whatever methods it provides to query screen dimensions. – John Bode Mar 30 '17 at 14:03
1 Answers
2
That is simply not possible to answer as a "pure C" question; there is no "screen" in C, i.e. the language and its standard library never assumes that there is any kind of screen-like output device available.
You need to settle for a suitable library for a portable solution, or figure out how to talk directly to your target environment.

unwind
- 391,730
- 64
- 469
- 606