943,998 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 53618
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Jan 30th, 2005
0

Can anyone help me using <graphics.h>

Expand Post »
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....
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
free_eagle is offline Offline
41 posts
since Jan 2005
Jan 30th, 2005
0

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

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.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Jan 30th, 2005
0

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

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
Reputation Points: 10
Solved Threads: 0
Light Poster
free_eagle is offline Offline
41 posts
since Jan 2005
Jan 31st, 2005
0

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

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!
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Jan 31st, 2005
0

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

Quote ...
#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
Reputation Points: 16
Solved Threads: 6
Posting Pro in Training
1o0oBhP is offline Offline
445 posts
since Dec 2004
Jan 31st, 2005
0

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

Quote 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 ....
Reputation Points: 10
Solved Threads: 0
Light Poster
free_eagle is offline Offline
41 posts
since Jan 2005
Jan 31st, 2005
0

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

Quote 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...
Reputation Points: 17
Solved Threads: 9
Posting Whiz in Training
frrossk is offline Offline
220 posts
since Sep 2004
Jan 31st, 2005
0

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

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 ....
Reputation Points: 10
Solved Threads: 0
Light Poster
free_eagle is offline Offline
41 posts
since Jan 2005
Jan 31st, 2005
0

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

Is there any way to graphics in windows. Plz not open gl. Its too difficult. Something as simple and easy as bgi graphics.
Reputation Points: 15
Solved Threads: 1
Junior Poster
chound is offline Offline
143 posts
since Aug 2004
Jan 31st, 2005
0

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

>>Is there any way to graphics in windows
Learn Windows API.
Reputation Points: 17
Solved Threads: 9
Posting Whiz in Training
frrossk is offline Offline
220 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in C++ Forum Timeline: Program Method HELP!!!
Next Thread in C++ Forum Timeline: Fibonacci recursive function





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC