3

So our teacher taught us to draw circles lines using c in turboc++, and my issue is, this compiler sucks, so I wanted to use some normal compiler or code editor, and I googled it, but those programs on websites which I found, use graphics.h for drawing circle, but my compiler is showing an error named no such file or directory. The same issue is seen when I use an online compiler.

So plz someone guide me where can I find some good material related to basic computer graphics whose c code does not need turboc++. It can be a book or website or videos on youtube.

Thanks in advance.

Nikhil
  • 63
  • 6
  • C does not have standard graphics. You need to use some third-party library. And there are choices to make. – Eugene Sh. Jan 18 '22 at 14:55
  • 1
    @Nikhil This is an excellent, excellent question. Stackoverflow won't like it, and will probably downvote and close it, but please don't let this discourage you. I dearly wish there were a good answer to your question. Unfortunately I don't know of one, either. – Steve Summit Jan 18 '22 at 14:57
  • C would be much more fun to learn if there were a simple, standard graphics library. People love to rag on Turbo C, but at least it had that. (Well, `` wasn't really "standard", but it was a *de facto* standard in the MS-DOS world.) – Steve Summit Jan 18 '22 at 14:59
  • @SteveSummit True, but adding a graphics library to the standard for the sole purpose of making it more fun to learn makes little sense :) – klutt Jan 18 '22 at 15:05
  • I doubt it is even possible because of *very* different C execution environments (unless these are drastically redefined). – Eugene Sh. Jan 18 '22 at 15:11
  • @EugeneSh. True, but it would be possible as a non-mandatory library. Compare to VLA:s. The standard does not say that an implementation needs to support them, but IF it does, the standard says how they shall behave. – klutt Jan 18 '22 at 15:13
  • 1
    @klutt On the contrary: C is an old, mature language, and unless it continues to gain fresh, competent practitioners, it will eventually die out. So I firmly believe it makes *very* good sense to pay attention to ease of learning! In fact I am seriously contemplating proposing an Annex (an optional one, of course, just like VLA's) addressing precisely this. (And something akin to `` was most definitely already on the list.) – Steve Summit Jan 18 '22 at 15:27
  • @SteveSummit I highly doubt that a standard library for graphics is critical for getting new people to learn the language. There are a lot of programmers that simply don't enjoy graphics programming. And for those who really want to do graphics programming in C, there are working solutions. – klutt Jan 18 '22 at 15:38
  • @SteveSummit Besides, even if I really enjoy C, I think it's time to slowly start retiring it. Sure, it's mature, but it also has a lot of bad things due to backwards compatibility. The biggest reason we still need C is to maintain old code. If C were invented today, it would not stand a chance. – klutt Jan 18 '22 at 15:59
  • @SteveSummit I'd say that one of the biggest drawbacks in C is the lack of things like containers in the stl. Coding C is basically reinventing the wheel over and over again. Even for such a basic thing as a linked list. – klutt Jan 18 '22 at 16:45
  • Windows or other ? –  Jan 18 '22 at 19:44
  • @klutt: I'd rather say that C++ suffers from backward compatibility to C. C has remained reasonably simple. C is currently more in use than C++. –  Jan 18 '22 at 19:47
  • @YvesDaoust Possibly, but regardless if C++ is worse or not, that's not really an argument for C. And there are many design flaws in C that will probably never go away. – klutt Jan 18 '22 at 20:29
  • @klutt: they even have percolated in a number of other languages :-( –  Jan 18 '22 at 20:35

1 Answers1

1

There is no standard graphics library in C. It's all third party. So you will never be able to write graphics code that's completely portable.

If you're using Linux, it's possible to use libgraph to enable the use of graphics.h. I found a question on askubuntu that covers this: How do I use graphics.h in Ubuntu?

If you're using Windows, it seems to be possible to use WinBGIm to use graphics.h. Geeks for geeks has instructions for how to use it with CodeBlocks https://www.geeksforgeeks.org/include-graphics-h-codeblocks/

I do not know how good these two options are, but they might be worth trying out. That will at least remove the Turbo dependency.

klutt
  • 30,332
  • 17
  • 55
  • 95
  • @Nikhil There is the GD module in Perl which is a wrapper around the C library [libGD](https://libgd.github.io/pages/about.html). I have always found GD (Perl) simple and capable. libGD might be smililar. Worth considering? – chandra Jan 18 '22 at 15:56