Author Topic: How to get my code worked?  (Read 234 times)

Offline jollydragon

  • Single posting newcomer
  • *
  • Posts: 2
How to get my code worked?
« 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.

Online sodev

  • Regular
  • ***
  • Posts: 280
Re: How to get my code worked?
« Reply #1 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.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6538
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline jollydragon

  • Single posting newcomer
  • *
  • Posts: 2
Re: How to get my code worked?
« Reply #3 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?



Offline stahta01

  • Lives here!
  • ****
  • Posts: 6538
    • My Best Post
Re: How to get my code worked?
« Reply #4 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
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

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.



« Last Edit: June 08, 2019, 05:54:04 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org