Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Looking for a nice free stable C/C++ platform to do some simple windows programming

Posted on 2004-09-10
Medium Priority
Last Modified: 2010-04-15
Hi.  I am trying to write a program that displays a small white square (8x8 pixels) on a black screen that is moving (using graphics), also the keyboard modifies the direction/acceleration of the square.  My problems are:
(1) I don't have C/C++ installed on my PC (I don't really know where to get a good free compiler)
(2) I'm not clear on how graphics work in C (will it be platform independent?)
(3) I can use the keyboard, but I need to detect every 10ms what the state of two keys are (up or down) to recalculate the cursor position, so its not detecting simple keypresses, etc.  I need to scan the key state every 10ms.

I know some of this stuff is easy, and I am familiar with C/C++, just haven't done it in a few years.  I'll even set this as a 150-point question just so that you're not wasting your time.

Any help would be welcome.  Thanks.

Question by:powertrain
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 23

Expert Comment

ID: 12031966
As for a free C/C++ compiler... MingW32 http://www.mingw.org/

As for the graphics work, you will need to use a third party library such as SDL:
LVL 23

Expert Comment

ID: 12032048
I mean as per the graphics, you have many options, but a graphics library isn't part of the basic
C++ language

You could also use DirectX for graphics, maybe someone else has a better link

Borland has "personal" versions of some of their development tools available for
free download... http://www.borland.com/products/downloads/download_cbuilderx.html

See here also: http://www.thefreecountry.com/compilers/cpp.shtml
LVL 11

Expert Comment

ID: 12032325
I found devcpp quite good

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 12032576
This may be a bit of a stretch if you prefer to stay on windows:

    linux: http://fedora.redhat.com/
    gcc: http://gcc.gnu.org/
    GDK is part of GNOME and could be used for graphics
    the keypress handling can be handled through the event/message mechanisms
LVL 22

Expert Comment

ID: 12034255
Don't forget the excellent www.openwatcom.org   compiler suite.  16 and 32-bits, real and DPMI and protect-mode.  Win 31, Win95/98/NT/XP.  Fast compiler nad good optimization.   Great manuals.
And good graphics libraries included.  And freee.  And still supported and being improved.


Expert Comment

ID: 12037265
2) as said above, C does not do graphics.  people write libraries (in C, but thats besides the point) that do graphics for you, such as openGL, or directX, or X, or the windows GUI API.  A library can be cross platform (openGL is), but usually the initialization (creating the initial window) is not.  You can look into GLUT if you really want cross-platform abilities.  GLUT is a GUI API that works under both Windows, and Unix (using X), and macintosh (obviously since osX is a unix variant, but I believe there is a GLUT variant for OS9) GLUT compiles into native API code for whatever system you compiled on (or are compiling for, if you do some command line tricks)
3) Reading the keyboard accuratly every 10ms is going to be hard.  under windows, DirectInput should be able to do similar.  But ask yourself how important is this EVERY 10ms?  If your harddrive is thrashing because the computer is bogged down, you might not get to execute your code every 10ms.  One thing you can do is track KEY_DOWN and KEY_UPs, and keep track of the state of the key.  A timer will then let you keep approximatly 10ms timing.  Threads will help you out for keeping the timers going at the right rate, but watch out for multirhtreading issues.

Are you actually using a keyboard?  10ms is 1/100th of a second.  Its hard for a human hand to have that kind of accuracy, and the human eye can't see that fast (I use PWM at these frequencies to give an LED the appearance of dimming).  Or is this a hacked apart connection to some hardware component that has 10ms accuracy.

Author Comment

ID: 12146828
Re: open watcom (grg99), I went to the openwatcom site and it looks like you have to pay for it.... is that true?

Re: timing issues (CmdrRickHunter), well actually its for an experiment with some specific requirements.  In actuality I will need to scan the state of the keyboard (2 keys) every 1ms (and store it) and perform the calculation to display the tiny square every 10ms.  If I put it that way, do you think it will be any more possible

Accepted Solution

CmdrRickHunter earned 600 total points
ID: 12148920
Windows is not a real-time OS (nor are most major OSes).  You can't be guarenteed to even run once per millisecond (much less check something every millisecond).  You might get lucky, and have it work, and be able to get the polling rate you want... or you might get unlucky and have your program get switched out of memory on you, and not be able to use it for 50ish ms.

as for displaying at 100Hz (10ms), it can be done, assuming your monitor does support 100Hz refresh rates.  be sure to tell the graphics language to "wait for refresh", and make sure you update at over 100Hz (so that you dont miss anything).

I dont know how strict your requirements are.  If you HAVE to poll every 1ms, on the ms, then you would have the best results writing a simple microcontroller to poll it, and tell the computer the states.  That way if it takes the computer 2ms to get around to executing your thread, it just has to handle two updates at once (not too hard).

If its okay to miss a poll every so often, you could try your luck with a OS specific keyboard reading function (something like DirectInput from the DirectX suite).  It might have the update rate you want, it might not.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question