Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: jollydragon on June 07, 2019, 08:44:58 am

Title: How to get my code worked?
Post by: jollydragon on June 07, 2019, 08:44:58 am


Please see the simple code below:


It's supposed to draw some green lines, but you can see it shows black screen below:


How should I fix it? Thanks.
Title: Re: How to get my code worked?
Post by: sodev on June 07, 2019, 03:43:02 pm
Isn't it part of your homework to figure out how BGI is setup? This is not the place to ask how to do your homework!

A quick google reveals that the initialization function needs to get passed a path to some part of BGI, passing a pointer to an uninitialized char doesn't seem to be the right thing, so it crashes.
Title: Re: How to get my code worked?
Post by: stahta01 on June 07, 2019, 05:14:47 pm
Read this website rules http://forums.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)
And, read this FAQ http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F)

Tim S.
Title: Re: How to get my code worked?
Post by: jollydragon on June 08, 2019, 09:47:27 am

Sorry to tell I'd searched 7hrs before I posted my previous post, and I failed to find answer for the issue I met.
It's weird I couldn't find the solution to my issue because I believe it's some general issue.

I installed the latest version of CodeBlocks on my win10, and copied graphics.h and winbgim.h into "include" folder, and libbgi.a into "lib" folder.
Then got the setting done as the screenshot below.
Then got the compiling succeeded, but there's some error happened as the screenshot in my previous post.

Believe, as the friend above told, that it's some issue with the BGI path.
But how to resolve it? Dos any additional BGI must be installed for my simple C code?


Title: Re: How to get my code worked?
Post by: stahta01 on June 08, 2019, 02:57:51 pm
I suggest reading the links I posted and then posting a build log. And, post OS, CB, and Compiler information.
Or, you can just be ignored by me.

Copying random files into a good MinGW GCC installation folder is a way to make it into a bad GCC installation.

Edit: Add link that could help https://github.com/stahta01/windows-games (https://github.com/stahta01/windows-games)
But, since you have yet to learn how to cut and paste it is likely over your head.

Edit2: Read the docs https://www.cs.colorado.edu/~main/bgi/doc/detectgraph.html (https://www.cs.colorado.edu/~main/bgi/doc/detectgraph.html)

The problem is bad code as sodev said.

Edit3: And, helping you fix your bad code if way off topic for this website!

Tim S.