Can anyone help me using <graphics.h>

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2005
Posts: 41
Reputation: free_eagle is an unknown quantity at this point 
Solved Threads: 0
free_eagle's Avatar
free_eagle free_eagle is offline Offline
Light Poster

Can anyone help me using <graphics.h>

 
0
  #1
Jan 30th, 2005
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 ...

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....
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Can anyone help me using <graphics.h>

 
0
  #2
Jan 30th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 41
Reputation: free_eagle is an unknown quantity at this point 
Solved Threads: 0
free_eagle's Avatar
free_eagle free_eagle is offline Offline
Light Poster

Re: Can anyone help me using <graphics.h>

 
0
  #3
Jan 30th, 2005
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 <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string.h>
#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
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,954
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 917
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Can anyone help me using <graphics.h>

 
0
  #4
Jan 31st, 2005
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!
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 445
Reputation: 1o0oBhP is an unknown quantity at this point 
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: Can anyone help me using <graphics.h>

 
0
  #5
Jan 31st, 2005
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string.h>
#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
http://sales.carina-e.com

no www
no nonsense

coming soon to a pc near you! :cool:
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 41
Reputation: free_eagle is an unknown quantity at this point 
Solved Threads: 0
free_eagle's Avatar
free_eagle free_eagle is offline Offline
Light Poster

Re: Can anyone help me using <graphics.h>

 
0
  #6
Jan 31st, 2005
Originally Posted by vegaseat
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 <graphics.h>
#include <conio.h>



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 ....
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 220
Reputation: frrossk is an unknown quantity at this point 
Solved Threads: 9
frrossk's Avatar
frrossk frrossk is offline Offline
Posting Whiz in Training

Re: Can anyone help me using <graphics.h>

 
0
  #7
Jan 31st, 2005
Originally Posted by free_eagle
#include "stdafx.h"
#include <graphics.h>
#include <conio.h>

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...
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 41
Reputation: free_eagle is an unknown quantity at this point 
Solved Threads: 0
free_eagle's Avatar
free_eagle free_eagle is offline Offline
Light Poster

Re: Can anyone help me using <graphics.h>

 
0
  #8
Jan 31st, 2005
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 ....
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 140
Reputation: chound is an unknown quantity at this point 
Solved Threads: 1
chound chound is offline Offline
Junior Poster

Re: Can anyone help me using <graphics.h>

 
0
  #9
Jan 31st, 2005
Is there any way to graphics in windows. Plz not open gl. Its too difficult. Something as simple and easy as bgi graphics.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 220
Reputation: frrossk is an unknown quantity at this point 
Solved Threads: 9
frrossk's Avatar
frrossk frrossk is offline Offline
Posting Whiz in Training

Re: Can anyone help me using <graphics.h>

 
0
  #10
Jan 31st, 2005
>>Is there any way to graphics in windows
Learn Windows API.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC