954,167 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Can anyone help me using <graphics.h>

Hi there ! How r u?

Ohh I really need your help great programmers ...
I am new for programming and I am trying to do things by myself but here I need your help :-|

I would like to draw something in C or C++ but I got no basic IDEA ...
For example any kinds of graphics I would like to draw but...
I searched internet but I couldn't find concrete answer please give me some data link where can I learn or give me some advise of yours please please ... :sad:

give me some examples how can I use graphics.h lib .

I tried to draw "sine wave" but I couldn't please help me with this ...

Thanks beforehand.... ;)

free_eagle
Light Poster
41 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

graphics.h is a very old library for doing graphics in DOS with Borland C++ 3.x.
It's not supported under Windows, and the compiler isn't supported either.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

Sorry may be I made my question not clear....

I just tried to draw y=sin(x) function graph just or something like that y=x+1 or e.t.c.

can you give me some hints for beginning my programm...

for example:

#include
#include
#include
#include
#include
#include "graphics.h"

#define ESC 0x1b

void main () {

srand(time(NULL));

int GraphDriver=0; GraphMode=0;

initgraph (&GraphDriver ,&GraphMode, "", 640,480);

char tempstring[80];

getch() ;

}

}

Please do help me with drawing this y = sin(x) graph......

Do forgive me If I make some misunderstanding ....
Thanks

free_eagle
Light Poster
41 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

There is a C++ code snippet right here on DaniWeb called "Add a little Graphics to your Console" at:
http://www.daniweb.com/code/snippet173.html

You could potentially draw short lines following the x,y coordinates of your sin(x) function.

Forget about the old graphics.h and Borland BGI DOS stuff, that was left in the 16 bit graveyard a long time ago!

vegaseat
DaniWeb's Hypocrite
Moderator
5,976 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,416
 

#include #include #include #include #include #include "graphics.h"

#define ESC 0x1b

void main () {

srand(time(NULL));

int GraphDriver=0; GraphMode=0;

initgraph (&GraphDriver ,&GraphMode, "", 640,480);

char tempstring[80];

getch() ;

}

}

Spotted a few errors (although i accept it is work in progress :) ): main should be declared as int main NOT void main....
...GraphMode is undefined as the previous ; finishes the statement (change the previous ; to a , ) and also ESC and tempstring are not used! also do you not have to shut down the driver at the end? - and bear in mind main returns 0; :p

1o0oBhP
Posting Pro in Training
445 posts since Dec 2004
Reputation Points: 16
Solved Threads: 6
 

There is a C++ code snippet right here on DaniWeb called "Add a little Graphics to your Console" at: http://www.daniweb.com/code/snippet173.html

You could potentially draw short lines following the x,y coordinates of your sin(x) function.

Forget about the old graphics.h and Borland BGI DOS stuff, that was left in the 16 bit graveyard a long time ago!


Thanks for suggestion but you know I hardly understand that code and here I am going to show you the code which I began first here and this is only drawing of X and Y oxes and I have to go on drawing sin(x) function please give me your suggestion....

-------------------------------------------------------------------------#include "stdafx.h"
#include
#include

void main()
{

int gd=DETECT, gm;
initgraph(&gd,&gm,"");

int x,y, j=250 ;

setbkcolor(WHITE);
setcolor(LIGHTBLUE);

outtextxy(3,5," I am so stupid hyong I am so stupid sorry sorry !!! "); // output "line" text


x = getmaxx();
y = getmaxy();

x=j;

line(j,0,x,y);

x = getmaxx();
y = getmaxy();

y=j;

line(0,j,x,y);




/*void line(int x0, int y0, int x1, int y1)

{
POINT line[2];
line[0].x = x0;
line[0].y = y0;
line[1].x = x1;
line[1].y = y1;
drawpoly(2, (int*)&line);
}
*/

getch();

closegraph(); // escape graphic mode
}

Thanks very much ....

free_eagle
Light Poster
41 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

#include "stdafx.h" #include #include

void main() { int gd=DETECT, gm; initgraph(&gd,&gm,"");

int x,y, j=250 ;

setbkcolor(WHITE); setcolor(LIGHTBLUE);

outtextxy(3,5," I am so stupid hyong I am so stupid sorry sorry !!! "); // output "line" text x = getmaxx(); y = getmaxy(); x=j;

line(j,0,x,y); x = getmaxx(); y = getmaxy(); y=j;

line(0,j,x,y); /*void line(int x0, int y0, int x1, int y1)

{ POINT line[2]; line[0].x = x0; line[0].y = y0; line[1].x = x1; line[1].y = y1; drawpoly(2, (int*)&line); } */

getch(); closegraph(); // escape graphic mode } Thanks very much ....

Jwenting says:
"graphics.h is a very old library for doing graphics in DOS with Borland C++ 3.x.
It's not supported under Windows, and the compiler isn't supported either."

I guess you are using Microsoft VC++...

1000BhP says:
"main should be declared as int main NOT void main...."

I don't think you have read their posts...

frrossk
Posting Whiz in Training
220 posts since Sep 2004
Reputation Points: 17
Solved Threads: 9
 

O.K ...O.K...O.K... :

Yes you are right I am using Microsoft VC++

Thanks much ...

NOw I c my mistakes thanks ...

NOw I am going to correct my mistakes

Thanks ....

free_eagle
Light Poster
41 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

Is there any way to graphics in windows. Plz not open gl. Its too difficult. Something as simple and easy as bgi graphics.

chound
Junior Poster
145 posts since Aug 2004
Reputation Points: 15
Solved Threads: 1
 

>>Is there any way to graphics in windows
Learn Windows API.

frrossk
Posting Whiz in Training
220 posts since Sep 2004
Reputation Points: 17
Solved Threads: 9
 

I want to do graphics in console type apps. What should I use?

chound
Junior Poster
145 posts since Aug 2004
Reputation Points: 15
Solved Threads: 1
 
I want to do graphics in console type apps. What should I use?

Please try this link

free_eagle
Light Poster
41 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 
Please try this link


free_eagle thanks for the link!!!!
I modified the package slightly, and was able to use it with Dev_C++
It works like a charm! I left a little code snippet on DaniWeb showing the details.

thanks again, team work at its best ...

vegaseat
DaniWeb's Hypocrite
Moderator
5,976 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,416
 

free_eagle thanks for the link!!!! I modified the package slightly, and was able to use it with Dev_C++ It works like a charm! I left a little code snippet on DaniWeb showing the details.

thanks again, team work at its best ...


YOu are welcome :surprised

I am very glad that I could do some useful thing here , even though I am very new in this kind of matters ...

I have been learning programming for three weeks...
Acctually I am majoring medecine so before I didn't have to study these programming languages ...

As nowadays I got 2 month vacation I decided to learn some programming language :cool:

AND Thanks to this Forum I am learning much things thanks to you very much members of this forum for your help ... :cool:

free_eagle
Light Poster
41 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

I hope you enjoy your adventures into the world of programming. The logic you learn will help your brain to think better. You are very welcome to ask questions on this forum, most of us are pretty friendly.

Give us enough detail to answer the question. Don't worry too much about the English, it's not my mother language either and I manage to get by.

vegaseat
DaniWeb's Hypocrite
Moderator
5,976 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,416
 

I hope you enjoy your adventures into the world of programming. The logic you learn will help your brain to think better. You are very welcome to ask questions on this forum, most of us are pretty friendly.

Give us enough detail to answer the question. Don't worry too much about the English, it's not my mother language either and I manage to get by.


Thanks very much for welcoming :!:

As the rule of this Forum first I have to make my effort to deserve your help.

Thanks much .... ^_^

free_eagle
Light Poster
41 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

Here is a one page reference to grpahics.h library with the details of more widely used functions of this library. Also a small program to demonstrate the graphics.

http://www.mycplus.com/Programming-News-Articles.asp?NewsID=33

msaqib
Junior Poster in Training
91 posts since Sep 2004
Reputation Points: 9
Solved Threads: 1
 

Hi there ! How r u?

Ohh I really need your help great programmers ... I am new for programming and I am trying to do things by myself but here I need your help :-|

I would like to draw something in C or C++ but I got no basic IDEA ... For example any kinds of graphics I would like to draw but... I searched internet but I couldn't find concrete answer please give me some data link where can I learn or give me some advise of yours please please ... :sad:

give me some examples how can I use graphics.h lib .

I tried to draw "sine wave" but I couldn't please help me with this ...

Thanks beforehand.... ;)


im renn can you help some graphics program to do coz 8s my big project in 1st. college pls reply hope u will read and appreciate this comment.

renn
Newbie Poster
1 post since Dec 2009
Reputation Points: 10
Solved Threads: 0
 
im renn can you help some graphics program to do coz 8s my big project in 1st. college pls reply hope u will read and appreciate this comment.


Do not reply to old threads if you not gone post solution. If you need help with your project create new thread, well explain in full sentence English and of course do not forget include relevant coding.

peter_budo
Code tags enforcer
Moderator
15,433 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 901
 

Post: Markdown Syntax: Formatting Help
You