You are here:

C++/Drawing shapes using turbo c


im using windows xp with the turbo c compiler

Followup To
Question -
Hello and good day
my name is Oz, and i'm been browsing millions of books and scanning the web for answers, but i always end up with errors. i need to draw a triangle and a diamon using turbo c. the tutorials and books i find keep giving me errors. can you please help me? thank you in advance :D
Answer -
Hello Oz, thank you for the question.

What operating system are you using?

- Eddie

Hello Oz, thank you for the question.

Windows is my forte. If you include the header file <Windows.h> you get access to all the windows GDI functions, which you can use to draw. The only functions it has premade to draw shapes are Ellipse() and Rectangle(). To draw your triangle and diamond, you would have to use the functions MoveToEx(), and LineTo(). The MoveToEx() function will move your drawing point on the screen, and the LineTo() function will actually draw your line. The first parameter to each is a HDC, which can be obtainted by calling GetDC(), and passing it the handle to your window that you get back from the call to CreateWindow. Please see the following links for further reference:

LineTo() -

MoveToEx() -

If you have any other questions, please don't hesistate to ask me another question. Also, if this happens to be a console application you're working on, let me know. This was assuming that you are making a Win32 app. A console app is weird with how you get the HDC for the window.

I hope this information was helpful.

- Eddie


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 All rights reserved.