Is it possible to drwa a graph in C?
Is it possible to drwa a graph in C?
Only by the cross are you saved...
er......i'm using Windows XP, er........along with Microsoft Visual C++ as my compiler...
i mainly want to generate a graph after i've been fed the data...
how do i draw a graph in C? hjow difficult is this and wat work do i need to do?
Only by the cross are you saved...
If you dont want to worry about learning anything with graphic libraries, just use a histogram, its crude, but a lot of times it does whats needed and shows the levels of a specific item.
Code:#include <stdio.h> #define SIZE 10 int main() { int n[SIZE] = {19, 3, 15, 7, 11, 9, 13, 5, 17, 1}; int i, j; printf("%s%13s%17s\n", "Element", "Value", "Histogram"); for (i = 0; i < SIZE; i++) { printf("%7d%13d ", i, n[i]); for(j = 1; j <= n[i]; j++) printf("%c", '*'); printf("\n"); } return 0; }
The keyboard is the standard device used to cause computer errors!
thanx for the histogram, hehe, it's an easy way out, i wouldn't mind using it...
but how hard is the real way of doing it?
Only by the cross are you saved...
Drawing graphics in a console is difficult, it is, in fact, easier to write a full GUI Windows app than fiddle a console for graphical output.
I'll attach a very basic Windows GUI program, (in VC++ open a new project and specify "Win32 Application" not Console), You can plot points for a graph with the SetPixel() API function for example.
If you have trouble with this, open a thread on the Windows specific board.
Unfortunately, my tutorial which describes this program is not on my new site yet.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
what about ncurses? has it been ported to dos/windows(and working well)? easy to use?Drawing graphics in a console is difficult, it is, in fact, easier to write a full GUI Windows app than fiddle a console for graphical output.
I stand by what I said. If you really need to do graphics on a Windows platform, It is just as easy/better to do it with the Win32 GUI.
Why limit yourself?
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
You don't need to limit yourself. Place the screen in graphics mode and draw the lines for the graph. Win32 GUI is messy and difficult. They could easily do graphics programs long before Windows was invented. http://wpattinson.com/bombsrch.zip is a non-GUI graphics program.Originally posted by adrianxw
I stand by what I said. If you really need to do graphics on a Windows platform, It is just as easy/better to do it with the Win32 GUI.
Why limit yourself?
Definition: Politics -- Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers
adrianxw, thanx but i need to try and do this in C, so i'm restricted to a console...
waltp, i can't seem to download from that link u sent me...
how do i place the screen in graphics mode? u mean the console screen has many modes or wat?
Only by the cross are you saved...