'Codeblocks runtime error with graphics.h based program

I tried running the program from this link in Codeblocks- https://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=7939&lngWId=3

The program runs but prematurely stops with an error- 'drawing operation was attempted when there was no current window'.

Can anyone suggest a fix for this or any alternative headers for graphics-based operations in C?

(N.B.:I'm using the default GNU GCC compiler)



Solution 1:[1]

You can use:

 char driver[] = "";
 initgraph(&gdriver, &gmode, driver);

at the start of your program.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BusyProgrammer